public void DeleteHouseCategory(LOAINHA loaiNha) { if (loaiNha is null) { throw new System.ArgumentNullException(nameof(loaiNha)); } using (var db = new QUANLYNHADATEntities()) { db.LOAINHAs.Remove(loaiNha); db.SaveChanges(); } this.Reset(); }
public void EditHouseCategory(LOAINHA loaiNha) { if (loaiNha is null) { throw new System.ArgumentNullException(nameof(loaiNha)); } using (var db = new QUANLYNHADATEntities()) { var houseCate = db.LOAINHAs.Find(loaiNha.MALOAI); if (houseCate != null) { houseCate.TEN = loaiNha.TEN; db.SaveChanges(); } } this.Reset(); }
private async void ExecuteDeleteHouseCategoryCommand(int cateId) { this.modifiedHouseCategory = LoaiNhaDAO.GetInstance().GetHouseCategoryById(cateId); var okeCancelDialogViewModel = new OkCancelDialogViewModel { Message = "Xóa loại nhà này?" }; var view = new OkCancelDialogControl { DataContext = okeCancelDialogViewModel }; //show the dialog var result = await DialogHost.Show(view, BaseMainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, DeleteHouseCategoryClosingEventHandler).ConfigureAwait(false); //check the result... Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }
private async void ExecuteEditHouseCategoryCommand(int cateId) { this.modifiedHouseCategory = LoaiNhaDAO.GetInstance().GetHouseCategoryById(cateId); this.HouseCategoryDetailViewModel = new HouseCategoryDetailViewModel { SelectedHouseCategory = this.modifiedHouseCategory }; var view = new HouseCategoryDetailDialog { DataContext = this.HouseCategoryDetailViewModel }; //show the dialog var result = await DialogHost.Show(view, BaseMainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, EditHouseCategoryClosingEventHandler).ConfigureAwait(false); //check the result... Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }