Apachai.Apachai.FetchInformations C# (CSharp) Method

FetchInformations() private method

private FetchInformations ( IManosContext ctx, string id ) : void
ctx IManosContext
id string
return void
        public void FetchInformations(IManosContext ctx, string id)
        {
            if (string.IsNullOrEmpty (id))
                ctx.Response.HandleEmptyJson ();

            string json;

            if (store.GetPicturesInfos (id, out json)) {
                Log.Info ("Fetching infos for {0} and returning: {1}", id.ToString (), json);
                ctx.Response.HandleJson (json);
                return;
            }

            if (!File.Exists (Path.Combine (imgDirectory, id))) {
                ctx.Response.HandleEmptyJson ();
                return;
            }

            Task.Factory.StartNew (() => {
                JsonStringDictionary dict = new JsonStringDictionary ();

                TagLibMetadata metadata = new TagLibMetadata (imgDirectory, id);
                if (!metadata.IsValid) {
                    Log.Info (id + " is invalid file");
                    json = string.Empty;
                } else {
                    metadata.FillUp (dict);
                    json = dict.Json;
                }
                metadata.Close ();

                store.SetPictureInfos (id, json);
                ctx.Response.HandleJson (json);
            });
        }