public ActionResult DeleteLHS(string id) { var loaiHoSo = _loaiHoSoService.Get(m => m.Id == id); var count = _hoSoService.Gets(p => p.LoaiHoSoId == id).Count(); if (count > 0) { TempData["AlertMessage"] = "Không Thể Xóa Vì Có " + count + " Hồ Sơ Phụ Thuộc"; return(RedirectToAction("Index", new { active = false })); } _loaiHoSoService.Remove(loaiHoSo); _functionLichSuHoatDongService.Create(ActionWithObject.Delete, User.Identity.GetUserId(), "loại hồ sơ: " + loaiHoSo.Ten); TempData["AlertMessage"] = "Xóa Loại Hồ Sơ Thành Công"; return(RedirectToAction("Index")); }
public ActionResult Delete(string id) { var hop = _hopService.Get(m => m.Id == id); var hosos = _hoSoService.Gets(m => m.HopId == id).Count(); if (hosos > 0) { TempData["AlertMessage"] = "Không Thể Xóa Vì Có " + hosos + " Hồ Sơ Phụ Thuộc"; return(RedirectToAction("Index", new { active = false })); } string chiTietHoatDong = "hộp " + hop.ChuyenDe + " trên kệ thứ " + hop.Ke.SoThuTu; UpdateTu_SoHopHienTai(hop.KeId, ActionWithObject.Delete); _hopService.Remove(hop); _functionLichSuHoatDongService.Create(ActionWithObject.Delete, User.Identity.GetUserId(), chiTietHoatDong); TempData["AlertMessage"] = "Xóa Thành Công"; return(RedirectToAction("Index")); }