Ejemplo n.º 1
0
        public static async Task <int> save(Receipt receipt)
        {
            int result = 0;

            try
            {
                string ItemsArr = "[";
                for (int i = 0; i < receipt.cartItems.Count; i++)
                {
                    ItemsArr += "{";
                    ItemsArr += "\"id\": \"" + receipt.cartItems[i].ProductoId.ToString() + "\",";
                    ItemsArr += "\"cantidad\": \"" + receipt.cartItems[i].Cantidad + "\",";
                    ItemsArr += "\"detalle\": \"" + receipt.cartItems[i].Descripcion + "\",";
                    ItemsArr += "\"precio\": \"" + receipt.cartItems[i].PrecioUnitario + "\",";
                    ItemsArr += "\"iva\": \"" + receipt.cartItems[i].Iva + "\",";
                    ItemsArr += "\"importe\": \"" + receipt.cartItems[i].Importe + "\"";
                    ItemsArr += "}";
                    if (i < receipt.cartItems.Count - 1)
                    {
                        ItemsArr += ",";
                    }
                }

                ItemsArr += "]";

                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "receipts"));
                cparams.Add(new CloureParam("topic", "guardar"));
                cparams.Add(new CloureParam("tipo_comprobante_id", receipt.TypeId.ToString()));
                cparams.Add(new CloureParam("cliente_id", receipt.CustomerId.ToString()));
                cparams.Add(new CloureParam("items", ItemsArr));
                cparams.Add(new CloureParam("entrega", receipt.Entrega.ToString()));
                cparams.Add(new CloureParam("forma_de_pago_id", receipt.FormaDePagoId.ToString()));
                cparams.Add(new CloureParam("forma_de_pago_entidad_id", receipt.FormaDePagoEntidadId.ToString()));
                cparams.Add(new CloureParam("forma_de_pago", receipt.FormaDePagoEntidadId.ToString()));
                cparams.Add(new CloureParam("forma_de_pago_data", receipt.FormaDePagoData));
                cparams.Add(new CloureParam("forma_de_pago_cobro", receipt.FormaDePagoCobro.Value.ToString("yyyy-mm-dd")));
                cparams.Add(new CloureParam("sucursal_id", receipt.CompanyBranchId.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");
                    result = CloureManager.ParseInt(api_response.GetNamedValue("ComprobanteId"));
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static async Task <Video> Get(int id)
        {
            Video item = new Video();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "videos"));
                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.Titulo = item_obj.GetNamedString("Titulo");
                    item.Uri    = new Uri(item_obj.GetNamedString("Url"));
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(item);
        }
Ejemplo n.º 3
0
        public static async Task <int> save(Place item)
        {
            int response = 0;

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "places"));
                cparams.Add(new CloureParam("topic", "guardar"));
                cparams.Add(new CloureParam("id", item.Id));
                cparams.Add(new CloureParam("nombre", item.Nombre));
                string res = await CloureManager.ExecuteAsync(cparams);

                JsonObject api_result = JsonObject.Parse(res);
                string     error      = api_result.GetNamedString("Error");
                if (error == "")
                {
                    response = CloureManager.ParseInt(api_result.GetNamedValue("Response"));
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                response = 0;
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(response);
        }
        public static async Task <CompanyBranch> Get(int id)
        {
            CompanyBranch itemResult = new CompanyBranch();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "company_branches"));
                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 itemObj = api_result.GetNamedObject("Response");
                    itemResult.Id      = CloureManager.ParseInt(itemObj.GetNamedValue("Id"));
                    itemResult.Name    = itemObj.GetNamedString("Nombre");
                    itemResult.Address = itemObj.GetNamedString("Direccion");
                    itemResult.Phone   = itemObj.GetNamedString("Telefono");
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(itemResult);
        }
        private async void LoadData()
        {
            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "my_account"));
                cparams.Add(new CloureParam("topic", "get_data"));
                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");
                    txtNombre.Text   = item_obj.GetNamedString("nombre");
                    txtApellido.Text = item_obj.GetNamedString("apellido");
                    txtMail.Text     = item_obj.GetNamedString("mail");
                    txtTelefono.Text = item_obj.GetNamedString("telefono");
                    imgPhoto.Source  = new BitmapImage(new Uri(item_obj.GetNamedString("imagen")));

                    txtPais.SelectedValue   = CloureManager.ParseInt(item_obj.GetNamedValue("pais_id"));
                    txtPaisN1.SelectedValue = CloureManager.ParseInt(item_obj.GetNamedValue("pais_n1_id"));
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public static async Task <int> save(BandArtist bandArtist)
        {
            int response = 0;

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "bands_artists"));
                cparams.Add(new CloureParam("topic", "guardar"));
                cparams.Add(new CloureParam("id", bandArtist.Id));
                cparams.Add(new CloureParam("nombre", bandArtist.Nombre));
                if (bandArtist.CloureImage != null)
                {
                    cparams.Add(new CloureParam("image", bandArtist.CloureImage));
                }
                string res = await CloureManager.ExecuteAsync(cparams);

                JsonObject api_result = JsonObject.Parse(res);
                string     error      = api_result.GetNamedString("Error");
                //returns id
                string respuesta = (api_result.GetNamedValue("Response")).ToString();
                if (error == "")
                {
                    response = CloureManager.ParseInt(api_result.GetNamedValue("Response"));
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                response = 0;
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(response);
        }
        public static async Task <int> save(CompanyBranch companyBranch)
        {
            int response = 0;

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "company_branches"));
                cparams.Add(new CloureParam("topic", "guardar"));
                cparams.Add(new CloureParam("id", companyBranch.Id));
                cparams.Add(new CloureParam("nombre", companyBranch.Name));
                cparams.Add(new CloureParam("direccion", companyBranch.Address));
                cparams.Add(new CloureParam("telefono", companyBranch.Phone));
                string res = await CloureManager.ExecuteAsync(cparams);

                JsonObject api_result = JsonObject.Parse(res);
                string     error      = api_result.GetNamedString("Error");
                if (error == "")
                {
                    //returns branch id
                    //JsonObject api_response = api_result.GetNamedObject("Response");
                    response = CloureManager.ParseInt(api_result.GetNamedValue("Response"));
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                response = 0;
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(response);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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", "videos"));
                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();
                        Video      item     = new Video();
                        item.Id     = CloureManager.ParseInt(register.GetNamedValue("Id"));
                        item.Titulo = register.GetNamedString("Titulo");
                        item.Uri    = new Uri(register.GetNamedString("Url"));

                        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);
        }
Ejemplo n.º 11
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"));
                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();
                        Show       item     = new Show();
                        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);
                        }

                        //Carga fotografos
                        item.Fotografos = new ObservableCollection <User>();

                        JsonArray fotografos_arr = register.GetNamedArray("Fotografos");
                        foreach (JsonValue fotografo_obj in fotografos_arr)
                        {
                            JsonObject fotografo_item = fotografo_obj.GetObject();
                            User       user           = new User();

                            JsonValue tmpval = fotografo_item.GetNamedValue("Id");
                            if (tmpval.ValueType == JsonValueType.Number)
                            {
                                user.id          = (int)fotografo_item.GetNamedNumber("Id");
                                user.nombre      = fotografo_item.GetNamedString("Nombre");
                                user.apellido    = fotografo_item.GetNamedString("Apellido");
                                user.razonsocial = user.apellido + ", " + user.nombre;
                                user.ImageURL    = new Uri(fotografo_item.GetNamedString("Imagen"));
                                user.grupo       = fotografo_item.GetNamedString("Grupo");
                                user.email       = fotografo_item.GetNamedString("Mail");
                                user.Fotos       = CloureManager.ParseInt(fotografo_item.GetNamedValue("Fotos"));

                                item.Fotografos.Add(user);
                            }
                        }

                        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);
        }
Ejemplo n.º 12
0
        public static async Task <ShowPersonalHistoryResponse> GetList(string filtro = "", string ordenar_por = "", string orden = "", string desde = "", string hasta = "", string movement_type = "", string sucursal = "0", int Page = 1)
        {
            ShowPersonalHistoryResponse respuesta = new ShowPersonalHistoryResponse();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "shows_personal_history"));
                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));
                }
                if (desde.Length > 0)
                {
                    cparams.Add(new CloureParam("desde", desde));
                }
                if (hasta.Length > 0)
                {
                    cparams.Add(new CloureParam("hasta", hasta));
                }
                if (sucursal.Length > 0)
                {
                    cparams.Add(new CloureParam("sucursal", sucursal));
                }
                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();
                        ShowPersonalHistoryItem item = new ShowPersonalHistoryItem();
                        item.Id     = CloureManager.ParseInt(register.GetNamedValue("Id"));
                        item.Fotos  = CloureManager.ParseInt(register.GetNamedValue("Fotos"));
                        item.ShowId = CloureManager.ParseInt(register.GetNamedValue("ShowId"));
                        item.Titulo = register.GetNamedString("Titulo");
                        //item.Fecha = register.GetNamedObject("ShowId");

                        respuesta.Items.Add(item);
                    }
                    respuesta.TotalPages   = (int)api_response.GetNamedNumber("TotalPaginas");
                    respuesta.TotalEventos = CloureManager.ParseInt(api_response.GetNamedValue("TotalEventos"));
                    respuesta.TotalFotos   = CloureManager.ParseInt(api_response.GetNamedValue("TotalFotos"));
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(respuesta);
        }
        public static async Task <CompanyBranchResponse> getList(string filtro = "", string ordenar_por = "", string orden = "", string sucursal = "0")
        {
            CompanyBranchResponse response = new CompanyBranchResponse();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "company_branches"));
                cparams.Add(new CloureParam("topic", "listar"));
                if (ordenar_por.Length > 0)
                {
                    cparams.Add(new CloureParam("ordenar_por", ordenar_por));
                }
                if (orden.Length > 0)
                {
                    cparams.Add(new CloureParam("orden", orden));
                }
                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();
                        CompanyBranch companyBranch = new CompanyBranch();
                        companyBranch.Id   = CloureManager.ParseInt(register.GetNamedValue("Id"));
                        companyBranch.Name = register.GetNamedString("Nombre");

                        JsonArray available_commands_arr = register.GetNamedArray("AvailableCommands");
                        companyBranch.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);
                            companyBranch.AvailableCommands.Add(availableCommand);
                        }

                        response.Items.Add(companyBranch);
                    }
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(response);
        }