public void Delete([FromRoute] int id) { var timesheet = _timesheetService.GetById(id); if (timesheet == null) { throw new Exception("Timesheet is not found."); } _timesheetService.Delete(timesheet); }
public async Task <ActionResult <TimesheetViewModel> > DeleteTimesheet(int id) { var timesheet = _timesheetService.GetById(id); if (timesheet == null) { return(NotFound("Không tìm thấy Id = " + id)); } try { await Task.Run(() => { _timesheetService.Delete(id); _timesheetService.SaveChanges(); }); } catch { throw new Exception(string.Format("Có lỗi xảy ra không thể xóa!")); } return(Ok()); }
public ActionResult Delete(int id) { timesheetService.Delete(id); return(RedirectToAction("Index")); }