コード例 #1
0
        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"));
        }