Example #1
0
        public void Delete([FromRoute] int id)
        {
            var timesheet = _timesheetService.GetById(id);

            if (timesheet == null)
            {
                throw new Exception("Timesheet is not found.");
            }

            _timesheetService.Delete(timesheet);
        }
Example #2
0
        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"));
        }