Esempio n. 1
0
        public static async Task <bool> save(ShowArticle article)
        {
            bool response = true;

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "shows_news"));
                cparams.Add(new CloureParam("topic", "guardar"));
                cparams.Add(new CloureParam("id", article.Id));
                cparams.Add(new CloureParam("artista_id", article.ArtistaId));
                cparams.Add(new CloureParam("title", article.Titulo));
                cparams.Add(new CloureParam("content", article.Contenido));
                string res = await CloureManager.ExecuteAsync(cparams);

                JsonObject api_result = JsonObject.Parse(res);
                string     error      = api_result.GetNamedString("Error");
                if (error != "")
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                response = false;
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(response);
        }
        private void lstItems_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            ListView listView = (ListView)sender;

            itemContextMenu.Items.Clear();

            ListView list = (ListView)sender;

            if (((FrameworkElement)e.OriginalSource).DataContext.GetType() == typeof(ShowArticle))
            {
                ShowArticle product = (ShowArticle)((FrameworkElement)e.OriginalSource).DataContext;

                if (product.AvailableCommands.Count > 0)
                {
                    foreach (AvailableCommand availableCommand in product.AvailableCommands)
                    {
                        MenuFlyoutItem menuFlyoutItem = new MenuFlyoutItem();
                        menuFlyoutItem.Text   = availableCommand.title;
                        menuFlyoutItem.Name   = availableCommand.name;
                        menuFlyoutItem.Tag    = product;
                        menuFlyoutItem.Click += MenuFlyoutItem_Click;
                        itemContextMenu.Items.Add(menuFlyoutItem);
                    }
                }

                if (itemContextMenu.Items.Count > 0)
                {
                    itemContextMenu.ShowAt(listView, e.GetPosition(listView));
                    var a = ((FrameworkElement)e.OriginalSource).DataContext;
                }
            }
        }
        public ShowsNewsAddPage()
        {
            this.InitializeComponent();

            txtFontSize.SelectedValue = 12;

            showArticle    = new ShowArticle();
            showArticle.Id = 0;
        }
        private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            MenuFlyoutItem menuFlyoutItem = (MenuFlyoutItem)sender;
            ShowArticle    product        = (ShowArticle)menuFlyoutItem.Tag;

            if (menuFlyoutItem.Name == "edit")
            {
                edit(product.Id);
            }
            if (menuFlyoutItem.Name == "delete")
            {
                DisplayDeleteDialog(product.Id);
            }
        }
Esempio n. 5
0
        public static async Task <ShowArticle> Get(int id)
        {
            ShowArticle item = new ShowArticle();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "shows_news"));
                cparams.Add(new CloureParam("topic", "obtener"));
                cparams.Add(new CloureParam("formato", "rtf"));
                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.Fecha = CloureManager.ParseDate(item_obj.GetNamedValue("Fecha"));
                    item.Contenido = item_obj.GetNamedString("Contenido");
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(item);
        }
Esempio n. 6
0
        public static async Task <GenericResponse> GetList(string filtro = "", string ordenar_por = "", string orden = "", int Page = 1)
        {
            GenericResponse response = new GenericResponse();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "shows_news"));
                cparams.Add(new CloureParam("topic", "listar"));
                if (filtro.Length > 0)
                {
                    cparams.Add(new CloureParam("filtro", filtro));
                }
                if (ordenar_por.Length > 0)
                {
                    cparams.Add(new CloureParam("ordenar_por", ordenar_por));
                }
                if (orden.Length > 0)
                {
                    cparams.Add(new CloureParam("orden", orden));
                }
                cparams.Add(new CloureParam("pagina", Page.ToString()));
                string res = await CloureManager.ExecuteAsync(cparams);

                JsonObject api_result = JsonObject.Parse(res);
                string     error      = api_result.GetNamedString("Error");
                if (error == "")
                {
                    JsonObject api_response = api_result.GetNamedObject("Response");
                    JsonArray  registers    = api_response.GetNamedArray("Registros");

                    foreach (JsonValue jsonValue in registers)
                    {
                        JsonObject  register = jsonValue.GetObject();
                        ShowArticle item     = new ShowArticle();
                        item.Id     = (int)register.GetNamedNumber("Id");
                        item.Titulo = register.GetNamedString("Titulo");

                        JsonArray available_commands_arr = register.GetNamedArray("AvailableCommands");
                        item.AvailableCommands = new List <AvailableCommand>();
                        foreach (JsonValue available_cmd_obj in available_commands_arr)
                        {
                            JsonObject       available_cmd_item  = available_cmd_obj.GetObject();
                            int              available_cmd_id    = (int)available_cmd_item.GetNamedNumber("Id");
                            string           available_cmd_name  = available_cmd_item.GetNamedString("Name");
                            string           available_cmd_title = available_cmd_item.GetNamedString("Title");
                            AvailableCommand availableCommand    = new AvailableCommand(available_cmd_id, available_cmd_name, available_cmd_title);
                            item.AvailableCommands.Add(availableCommand);
                        }



                        response.Items.Add(item);
                    }

                    response.TotalPages = (int)api_response.GetNamedNumber("TotalPaginas");
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(response);
        }
        private async void Load_Data()
        {
            showArticle = await ShowsNews.Get(showArticle.Id);

            editor.Document.SetText(TextSetOptions.FormatRtf, showArticle.Contenido);
        }
        private void lstItems_ItemClick(object sender, ItemClickEventArgs e)
        {
            ShowArticle product = (ShowArticle)e.ClickedItem;

            edit(product.Id);
        }