private async Task UpdateCategory(CategoriesDetailsPage page, CategoryDto vm) { await _pageService.PopAsync(); _repository.UpdateCategory(vm); MessagingCenter.Send(this, MessagingString.RefreshCategory); }
public CategoriesViewModel(List <CategoryDto> categories, IPageService pageService, IRepository repository) { this.Categories = categories; SelectedType = TransactionType.Expense; this.filter = (x) => { return(x.Type == selectedType); }; _pageService = pageService; this._repository = repository; categoriesDetailsPage = new CategoriesDetailsPage(_pageService, _repository, new CategoryDto()); RefreshCommand = new Command(CmdRefresh); SelectCategoryCommand = new Command <CategoryDto>(async vm => await SelectCategory(vm)); DeleteActionCommand = new Command <CategoryDto>(async vm => await DeleteAction(vm)); EditActionCommand = new Command <CategoryDto>(async vm => await EditAction(vm)); NewCategoryCommand = new Command <CategoryDto>(async vm => await NewAction()); SearchCommand = new Command <string>(s => Search(s)); IncomeSelectedCommand = new Command(IncomeSelected); ExpenseSelectedCommand = new Command(ExpenseSelected); MessagingCenter.Unsubscribe <CategoryDetailsViewModel, CategoryDto>(this, MessagingString.UpdateCategory); MessagingCenter.Subscribe <CategoriesDetailsPage, CategoryDto>(this, MessagingString.UpdateCategory, async(page, vm) => { await UpdateCategory(page, vm); }); }