private async void Delete() { var caregoryView = CategoriesViewModel.GetInstance(); try { if (dialogService == null) { dialogService = new DialogService(); } var responseDelete = await dialogService.ShowConfirm("Confirm", "Are your sore to delete this record,?"); if (!responseDelete) { return; } caregoryView.IsRefreshing = true; var mainviewmodel = MainViewModel.GetInstance(); if (apiService == null) { apiService = new ApiService(); } var response = await apiService.Delete( "http://192.168.0.100", "/productsApi/api", "/Categories", mainviewmodel.Token.TokenType, mainviewmodel.Token.AccessToken, this); if (response.IsSuccess) { caregoryView.Categories.Remove(this); return; } else { caregoryView.IsRefreshing = false; await dialogService.ShowMessage("Error", response.Message); } } catch (Exception ex) { if (navigationService == null) { dialogService = new DialogService(); } await dialogService.ShowMessage("Error", ex.Message); } finally { caregoryView.IsRefreshing = false; } }
async void Delete() { var response = await dialogService.ShowConfirm("Confirm", "Are you sure to delet this record?"); if (!response) { return; } await CategoriesViewModel.GetInstance().DeleteCategory(this); }
async void Delete() { var response = await dialogService.ShowConfirm( "Alerta", "¿Estás seguro de eliminar este registro?"); if (!response) { return; } await CategoriesViewModel.GetInstance().DeleteCategory(this); }
public ExpenseDetailViewModel(Expense expense) { Expense = expense; Title = "Expense Details"; catViewModel = CategoriesViewModel.GetInstance(); Categories = catViewModel.GetAllCategories().ToList(); PopulateCategoryNames(); if (Expense.CategoryId > 0) { Expense.Category = Categories.FirstOrDefault(c => c.Id == Expense.CategoryId); Expense.CategoryName = Expense.Category.Name; } }
async void Delete() { var response = await dialogService.ShowConfirm( "Confirm", "Are you sure to delete this record?"); if (!response) { return; } //llamamos al CategoriesViewModel, instanciamos por el singleton,llamamos al metodo de delete, pasandole el objeto actual CategoriesViewModel.GetInstance().DeleteCategory(this); }
public NewExpensePage() { InitializeComponent(); catViewModel = CategoriesViewModel.GetInstance(); Categories = catViewModel.GetAllCategories().ToList(); Expense = new Expense() { Name = "", Date = DateTime.Now, Value = 0, Category = null, CategoryName = Categories.FirstOrDefault().Name }; Today = DateTime.Now.Date.ToLocalTime(); BindingContext = this; PopulateCategoryNames(); categoryPicker.ItemsSource = CategoryNames; SetSelectedItem(); }
public CategoriesPage() { InitializeComponent(); viewModel = CategoriesViewModel.GetInstance(); BindingContext = viewModel; }