예제 #1
0
        public static async Task <Show> Get(int id)
        {
            Show item = new Show();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "shows"));
                cparams.Add(new CloureParam("topic", "obtener"));
                cparams.Add(new CloureParam("id", id));
                string res = await CloureManager.ExecuteAsync(cparams);

                JsonObject api_result = JsonObject.Parse(res);
                string     error      = api_result.GetNamedString("Error");
                if (error == "")
                {
                    JsonObject item_obj = api_result.GetNamedObject("Response");
                    item.Id        = CloureManager.ParseInt(item_obj.GetNamedValue("Id"));
                    item.ArtistaId = CloureManager.ParseInt(item_obj.GetNamedValue("ArtistaId"));
                    item.LugarId   = CloureManager.ParseInt(item_obj.GetNamedValue("LugarId"));
                    item.Fecha     = CloureManager.ParseDate(item_obj.GetNamedValue("Fecha"));

                    JsonArray fotografosArr = item_obj.GetNamedArray("Fotografos");
                    item.Fotografos = new ObservableCollection <User>();

                    foreach (JsonValue fotografoItem in fotografosArr)
                    {
                        JsonObject fotografo     = fotografoItem.GetObject();
                        User       fotografoUser = new User();
                        fotografoUser.id          = CloureManager.ParseInt(fotografo.GetNamedValue("Id"));
                        fotografoUser.nombre      = fotografo.GetNamedString("Nombre");
                        fotografoUser.apellido    = fotografo.GetNamedString("Apellido");
                        fotografoUser.razonsocial = fotografoUser.apellido + ", " + fotografoUser.nombre;
                        fotografoUser.email       = fotografo.GetNamedString("Mail");
                        fotografoUser.grupo       = fotografo.GetNamedString("Grupo");
                        fotografoUser.ImageURL    = new Uri(fotografo.GetNamedString("Imagen"));
                        fotografoUser.Fotos       = CloureManager.ParseInt(fotografo.GetNamedValue("Fotos"));
                        item.Fotografos.Add(fotografoUser);
                    }
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(item);
        }