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(); } }
public static async Task <bool> Send(string Type, string Message) { bool result = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "support")); cparams.Add(new CloureParam("topic", "send")); cparams.Add(new CloureParam("message_type", Type)); cparams.Add(new CloureParam("message", Message)); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); if (error == "") { string api_response = api_result.GetNamedString("Response"); } else { result = false; throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(result); }
public static async Task <bool> isMonthlyIncomingExceded() { bool response = false; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "finances")); cparams.Add(new CloureParam("topic", "is_monthly_incoming_exceeded")); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); if (error == "") { response = CloureManager.ParseBoolObject(api_result.GetNamedValue("Response")); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public static async Task <User> GetUser(string userToken) { User user = new User(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "users")); cparams.Add(new CloureParam("topic", "get_by_token")); cparams.Add(new CloureParam("usr_token", userToken)); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); if (error == "") { JsonObject user_obj = api_result.GetNamedObject("Response"); user = load_data(user_obj); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(user); }
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 <bool> GeneratePass(int id) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "users")); cparams.Add(new CloureParam("topic", "reasignar_clave_random")); cparams.Add(new CloureParam("id", id.ToString())); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); string response_str = api_result.GetNamedString("Response"); if (error == "") { CloureManager.ShowDialog("Se ha generado la nueva clave: " + response_str); } else { throw new Exception(error); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public static async Task <JsonObject> GetClourePlans(string code = "") { JsonObject response = null; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("topic", "get_cloure_plans")); cparams.Add(new CloureParam("pid", code)); string res = await CloureManager.ExecuteAsync(cparams); //CloureManager.ShowDialog(res); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); if (error == "") { response = api_result.GetNamedObject("Response"); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public static async Task <bool> Delete(int id) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "shows_news")); cparams.Add(new CloureParam("topic", "borrar")); cparams.Add(new CloureParam("id", id)); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); string response_str = api_result.GetNamedString("Response"); if (error == "") { var dialog = new MessageDialog(response_str); await dialog.ShowAsync(); } else { throw new Exception(error); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public static async Task <BandArtist> Get(int id) { BandArtist item = new BandArtist(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "bands_artists")); cparams.Add(new CloureParam("topic", "obtener")); cparams.Add(new CloureParam("id", id.ToString())); 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 = (int)item_obj.GetNamedNumber("Id"); item.Nombre = item_obj.GetNamedString("Nombre"); item.ImageUrl = new Uri(item_obj.GetNamedString("Imagen")); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(item); }
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); }
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); }
public static async Task <UserGroup> Get(string id) { UserGroup item = new UserGroup(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "users_groups")); 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.Name = item_obj.GetNamedString("Id"); item.IsStaff = CloureManager.ParseBoolObject(item_obj.GetNamedValue("PerteneceAEmpresa")); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(item); }
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); }
public static async Task <bool> save(DebitCard debitCard) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "debit_cards")); cparams.Add(new CloureParam("topic", "guardar")); cparams.Add(new CloureParam("id", debitCard.Id.ToString())); cparams.Add(new CloureParam("nombre", debitCard.Name)); 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"); } else { throw new Exception(error); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public static async Task <JsonObject> printCC(int user_id) { JsonObject response = null; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "finances")); cparams.Add(new CloureParam("topic", "export_pdf_cc")); cparams.Add(new CloureParam("usuario_id", user_id)); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); if (error == "") { response = api_result.GetNamedObject("Response"); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
private async void change_pass() { try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "my_account")); cparams.Add(new CloureParam("topic", "cambiar_clave")); cparams.Add(new CloureParam("old_pass", txtOldPass.Password)); cparams.Add(new CloureParam("new_pass", txtNewPass.Password)); cparams.Add(new CloureParam("repeat_pass", txtRepeatPass.Password)); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); string respuesta = api_result.GetNamedString("Response"); if (error == "") { var dialog = new MessageDialog(respuesta); await dialog.ShowAsync(); CloureManager.GoBack(); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } }
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); }
public static async Task <bool> save(Show show) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "shows")); cparams.Add(new CloureParam("topic", "guardar")); cparams.Add(new CloureParam("id", show.Id)); cparams.Add(new CloureParam("date_time", show.Fecha.Value.ToString("yyyy-MM-dd"))); cparams.Add(new CloureParam("artista_id", show.ArtistaId)); cparams.Add(new CloureParam("lugar_id", show.LugarId)); cparams.Add(new CloureParam("images", show.Images)); if (show.Fotografos != null) { string ItemsArr = "["; for (int i = 0; i < show.Fotografos.Count; i++) { ItemsArr += "{"; ItemsArr += "\"id\": \"" + show.Fotografos[i].id.ToString() + "\","; ItemsArr += "\"fotos\": \"" + show.Fotografos[i].Fotos + "\""; ItemsArr += "}"; if (i < show.Fotografos.Count - 1) { ItemsArr += ","; } } ItemsArr += "]"; cparams.Add(new CloureParam("fotografos", ItemsArr)); } string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); JsonObject error = api_result.GetNamedValue("Error").GetObject(); ApiError apiError = new ApiError(error.GetNamedString("message")); if (apiError.message == "") { //JsonObject api_response = api_result.GetNamedObject("Response"); } else { throw new Exception(apiError.message); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public static async Task <GenericResponse> GetList(string filtro = "", string ordenar_por = "", string orden = "", int Page = 1) { GenericResponse genericResponse = new GenericResponse(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "receipts")); 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"); genericResponse.TotalPages = (int)api_response.GetNamedNumber("TotalPaginas"); foreach (JsonValue jsonValue in registers) { JsonObject register = jsonValue.GetObject(); Receipt receipt = new Receipt(); receipt.Id = (int)register.GetNamedNumber("Id"); receipt.FechaStr = register.GetNamedString("FechaStr"); receipt.Description = register.GetNamedString("Detalles"); receipt.Total = CloureManager.ParseNumber(register.GetNamedValue("Total")); receipt.TotalStr = register.GetNamedString("TotalStr"); genericResponse.Items.Add(receipt); } genericResponse.PageString = api_response.GetNamedString("PageString"); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(genericResponse); }
public static async Task <bool> save(ProductService product) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "products_services")); cparams.Add(new CloureParam("topic", "guardar")); cparams.Add(new CloureParam("id", product.Id.ToString())); cparams.Add(new CloureParam("tipo_producto_id", product.ProductTypeId.ToString())); cparams.Add(new CloureParam("sistema_medida_id", product.MeasureUnitId.ToString())); cparams.Add(new CloureParam("titulo", product.Title)); cparams.Add(new CloureParam("descripcion", product.Descripcion)); cparams.Add(new CloureParam("iva", product.IVA)); cparams.Add(new CloureParam("costo_precio", product.CostoPrecio)); cparams.Add(new CloureParam("costo_importe", product.CostoImporte)); cparams.Add(new CloureParam("venta_precio", product.VentaPrecio)); cparams.Add(new CloureParam("venta_importe", product.VentaImporte)); cparams.Add(new CloureParam("images", product.Images)); if (product.Stock != null) { string stock_str = "["; foreach (ProductStock productStock in product.Stock) { stock_str += "{"; stock_str += "\"inmueble_id\":\"" + productStock.PropiedadId + "\","; stock_str += "\"min\":\"" + productStock.Min.ToString("F2", CultureInfo.InvariantCulture) + "\","; stock_str += "\"actual\":\"" + productStock.Actual.ToString("F2", CultureInfo.InvariantCulture) + "\""; stock_str += "},"; } stock_str = stock_str.TrimEnd(','); stock_str += "]"; cparams.Add(new CloureParam("stock", stock_str)); } 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"); } else { throw new Exception(error); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public static async Task <GenericResponse> GetList(string filtro = "", string ordenar_por = "", string orden = "", int Page = 1) { GenericResponse genericResponse = new GenericResponse(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "bank_checks")); cparams.Add(new CloureParam("topic", "listar")); 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(); BankCheck item = new BankCheck(); item.Id = (int)register.GetNamedNumber("Id"); item.Descripcion = register.GetNamedString("Descripcion"); item.Cliente = register.GetNamedString("Cliente"); 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); } genericResponse.Items.Add(item); } genericResponse.PageString = api_response.GetNamedString("PageString"); } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(genericResponse); }
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", "linked_accounts")); 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(); LinkedAccount item = new LinkedAccount(); item.Name = register.GetNamedString("Name"); item.Title = register.GetNamedString("Title"); item.ImageURL = register.GetNamedString("Image"); item.Status = register.GetNamedString("Status"); response.Items.Add(item); } } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public async static Task <List <ModulePrivileges> > GetPrivileges(string grupo_id = "") { List <ModulePrivileges> items = new List <ModulePrivileges>(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("topic", "get_modules_privileges")); cparams.Add(new CloureParam("grupo_id", grupo_id)); 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(); ModulePrivileges modulePrivileges = new ModulePrivileges(); modulePrivileges.ClourePrivileges = new List <ClourePrivilege>(); modulePrivileges.ModuleTitle = register.GetNamedString("Title"); modulePrivileges.ModuleId = register.GetNamedString("Id"); JsonArray privileges_tmp = register.GetNamedArray("Privileges"); foreach (JsonValue privilege_tmp in privileges_tmp) { JsonObject privilegeObj = privilege_tmp.GetObject(); ClourePrivilege item = new ClourePrivilege(); item.Id = privilegeObj.GetNamedString("Id"); item.Title = privilegeObj.GetNamedString("Titulo"); item.Type = privilegeObj.GetNamedString("Type"); item.Value = privilegeObj.GetNamedString("Value"); modulePrivileges.ClourePrivileges.Add(item); } items.Add(modulePrivileges); } } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(items); }
public async static Task <List <UserGroup> > GetList() { List <UserGroup> items = new List <UserGroup>(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "users_groups")); cparams.Add(new CloureParam("topic", "get_list")); 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(); UserGroup item = new UserGroup(); item.Id = register.GetNamedString("Id"); item.Name = register.GetNamedString("Nombre"); item.Type = register.GetNamedString("TipoGrupoId"); item.IsStaff = CloureManager.ParseBoolObject(register.GetNamedValue("PerteneceAEmpresa")); 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); } items.Add(item); } } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(items); }
public static async Task <List <Bank> > getList(string filtro = "") { List <Bank> response = new List <Bank>(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "banks")); cparams.Add(new CloureParam("topic", "listar")); 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(); Bank item = new Bank(); item.Id = (int)register.GetNamedNumber("Id"); item.Name = register.GetNamedString("Nombre"); item.Web = register.GetNamedString("Web"); item.OnlineBanking = register.GetNamedString("OnlineBanking"); 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.Add(item); } } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
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); }
public static async Task <Receipt> Get(int id) { Receipt receipt = new Receipt(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "receipts")); cparams.Add(new CloureParam("topic", "obtener")); cparams.Add(new CloureParam("id", id.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"); receipt.CustomerName = api_response.GetNamedString("Usuario"); receipt.CustomerAddress = api_response.GetNamedString("UsuarioDomicilio"); receipt.Total = CloureManager.ParseNumber(api_response.GetNamedValue("Total")); List <CartItem> items = new List <CartItem>(); JsonArray values = api_response.GetNamedArray("Items"); foreach (JsonValue jsonValue in values) { double cant = 0; JsonObject item_obj = jsonValue.GetObject(); CartItem item = new CartItem(); item.ProductoId = (int)item_obj.GetNamedNumber("ProductoId"); item.Cantidad = CloureManager.ParseNumber(item_obj.GetNamedValue("Cantidad")); item.Descripcion = item_obj.GetNamedString("Detalles"); item.Importe = CloureManager.ParseNumber(item_obj.GetNamedValue("Importe")); item.Total = CloureManager.ParseNumber(item_obj.GetNamedValue("Total")); items.Add(item); } receipt.cartItems = items; } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(receipt); }
public static async Task <bool> Save(List <ModuleSettings> moduleSettings) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "settings")); cparams.Add(new CloureParam("topic", "save")); if (moduleSettings != null) { } string str_content = "["; foreach (ModuleSettings module in moduleSettings) { foreach (CloureSetting setting in module.CloureSettings) { str_content += "{"; str_content += "\"module_id\":\"" + module.ModuleId + "\","; str_content += "\"option\":\"" + setting.Id + "\","; str_content += "\"type\":\"" + setting.Type + "\","; str_content += "\"value\":\"" + setting.Value + "\""; str_content += "},"; } } str_content = str_content.TrimEnd(','); str_content += "]"; cparams.Add(new CloureParam("settings", str_content)); 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"); } else { throw new Exception(error); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public static async Task <bool> save(User user) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "users")); cparams.Add(new CloureParam("topic", "guardar")); cparams.Add(new CloureParam("id", user.id)); cparams.Add(new CloureParam("nombre", user.nombre)); cparams.Add(new CloureParam("apellido", user.apellido)); cparams.Add(new CloureParam("grupo_id", user.grupo_id)); cparams.Add(new CloureParam("empresa", user.empresa)); cparams.Add(new CloureParam("genero_id", user.GeneroId)); cparams.Add(new CloureParam("mail", user.email)); cparams.Add(new CloureParam("salario_bruto", user.salario)); cparams.Add(new CloureParam("comision", user.comision)); if (user.CloureImage != null) { cparams.Add(new CloureParam("uploaded_image", user.CloureImage)); } 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"); if (user.id == 0) { string msg = "Usuario guardado con éxito!\nClave generada: " + api_response.GetNamedString("clave_raw"); CloureManager.ShowDialog(msg); } } else { throw new Exception(error); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
public async static Task <bool> save(UserGroup userGroup) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "users_groups")); cparams.Add(new CloureParam("topic", "guardar")); cparams.Add(new CloureParam("id", userGroup.Id)); cparams.Add(new CloureParam("nombre", userGroup.Name)); cparams.Add(new CloureParam("pertenece_a_la_empresa", userGroup.IsStaff)); string str_content = "["; foreach (ModulePrivileges module in userGroup.ModulePrivileges) { foreach (ClourePrivilege privilege in module.ClourePrivileges) { str_content += "{"; str_content += "\"module_id\":\"" + module.ModuleId + "\","; str_content += "\"option\":\"" + privilege.Id + "\","; //str_content += "\"type\":\"" + privilege.Type + "\","; str_content += "\"value\":\"" + privilege.Value.ToString() + "\""; str_content += "},"; } } str_content = str_content.TrimEnd(','); str_content += "]"; cparams.Add(new CloureParam("privilegios", str_content)); 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"); } else { throw new Exception(error); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }