public async void Delete(int index, int?id) { if (id != null) { var window = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); var result = WinUIMessageBox.Show(window, "Bạn có muốn xóa giá trị này?", "Xác nhận", MessageBoxButton.YesNo, MessageBoxImage.None, MessageBoxResult.None, MessageBoxOptions.None, FloatingMode.Window); if (result == MessageBoxResult.Yes) { bool del = await timeRepo.Delete((int)id); if (del) { timeRules.RemoveAt(index); message = MessageHelper.Get("del"); } else { message = MessageHelper.Get("delErr"); } } } else { message = MessageHelper.Get("delNoti"); } }
public int Delete(Time time) { int result = 0; if (string.IsNullOrEmpty(time.LogId.ToString())) { MessageBox.Show("Log ID harus diisi!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(0); } using (DbContext context = new DbContext()) { _repository = new TimeRepository(context); result = _repository.Delete(time); } if (result == 0) { MessageBox.Show("Log gagal dihapus!", "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public void Delete(int Id) { repo.Delete(Id); }