private async void DeleteProduct_Clicked(object sender, EventArgs e) { try { var vProduct = this.BindingContext as DataContracts.Model.Product; //HACER VALIDACION AQUI ********************** var vClient = new BusinessProxy.Product.DeleteUserProduct(); var vDeteleProductRequest = new BusinessProxy.Models.ProductRequest() { SSOT = App.SSOT, UserId = App.ActualUser.UserId, UserProduct = vProduct }; var vResponse = await vClient.GetDataAsync(vDeteleProductRequest); if (vResponse != null && vResponse.IsSuccessful) { App.ShowLoading(false); await Navigation.PopAsync(); await Toasts.ToastRunner.ShowSuccessToast("Sistema", "Se ha eliminado Satisfactoriamente"); } else { App.ShowLoading(false); await DisplayAlert("", vResponse.TechnicalMessage, "Ok"); await Toasts.ToastRunner.ShowErrorToast("Sistema", vResponse.UserMessage); } } catch (Exception ex) { App.ShowLoading(false); await DisplayAlert("", ex.ToString(), "Ok"); } /*App.ShowLoading(true); * var deleteProduct = this.BindingContext as Model.Product; * var answer = await DisplayAlert("Sistema", "Estas seguro que deseas eliminar el item", "Si", "No"); * if (deleteProduct != null && answer) * { * if (await DynamoDBManager.GetInstance().Delete<Model.Product>( * deleteProduct * )) * { * App.ShowLoading(false); * await Toasts.ToastRunner.ShowSuccessToast("Sistema", "Se ha eliminado el item"); * this.SendBackButtonPressed(); * } * else{ * App.ShowLoading(false); * await Toasts.ToastRunner.ShowErrorToast("Sistema", "Se ha producido un error al contactar el servicio"); * } * * }*/ }
private async void AddProduct_Clicked(object sender, EventArgs e) { App.ShowLoading(true); try { var vNewProduct = this.BindingContext as DataContracts.Model.Product; //HACER VALIDACION AQUI ********************** var vClient = new BusinessProxy.Product.AddUserProduct(); var vAddProductRequest = new BusinessProxy.Models.ProductRequest() { SSOT = App.SSOT, UserId = App.ActualUser.UserId, UserProduct = vNewProduct }; string test = JsonConvert.SerializeObject(vAddProductRequest); var vResponse = await vClient.GetDataAsync(vAddProductRequest); if (vResponse != null && vResponse.IsSuccessful) { App.ShowLoading(false); await Navigation.PopAsync(); await Toasts.ToastRunner.ShowSuccessToast("Sistema", "Se ha Guardado Satisfactoriamente"); } else { App.ShowLoading(false); await DisplayAlert("", vResponse.TechnicalMessage, "Ok"); await Toasts.ToastRunner.ShowErrorToast("Sistema", vResponse.UserMessage); } } catch (Exception ex) { App.ShowLoading(false); await DisplayAlert("", ex.ToString(), "Ok"); } /*App.ShowLoading(true); * var NewProduct = this.BindingContext as DataContracts.Model.Product; * if (NewProduct!= null && !string.IsNullOrEmpty(NewProduct.Code) && !string.IsNullOrEmpty(NewProduct.Description) && * NewProduct.Price != 0 && UnityPicker.SelectedItem != null && !string.IsNullOrEmpty(Convert.ToString(UnityPicker.SelectedItem))) * { * try * { * NewProduct.UnityType = Convert.ToString(UnityPicker.SelectedItem); * if (await DynamoDBManager.GetInstance().SaveAsync<Model.Product>( * NewProduct * )) * { * App.ShowLoading(false); * await Toasts.ToastRunner.ShowSuccessToast("Sistema", "Se ha Guardado Satifactoriamente"); * this.SendBackButtonPressed(); * } * else * { * App.ShowLoading(false); * await Toasts.ToastRunner.ShowErrorToast("Sistema", "Se ha producido un error al contactar el servicio"); * } * * } * catch (Exception ex) * { * App.ShowLoading(false); * await Toasts.ToastRunner.ShowErrorToast("Sistema", ex.Message); * } * * } * else * { * App.ShowLoading(false); * await Toasts.ToastRunner.ShowInformativeToast("Sistema", "Alguno de los datos falta por rellenar"); * }*/ }