public bool UpdateTu_SoLuongHienTai(string id, ActionWithObject action) { int soluong = 0; var tu = _tuService.GetById(id); if (tu == null) { return(false); } soluong = Compute.ComputeAmountWithAction(tu.SoLuongHienTai, action); if (soluong > tu.SoLuongMax) { ViewBag.Tus = SelectListItemFromDomain.SelectListItem_Tu(_tuService.GetAll(m => m.OrderBy(t => t.Ten))); return(false); } else { tu.SoLuongHienTai = soluong; _tuService.Update(tu); return(true); } }
public ActionResult Delete(string id) { var tu = _tuService.GetById(id); var kes = _keService.Gets(p => p.Tuid == id).Count(); if (kes > 0) { TempData["AlertMessage"] = "Không Thể Xóa Vì Có " + kes + " Kệ Phụ Thuộc"; return(RedirectToAction("Index", new { active = false })); } _functionLichSuHoatDongService.Create(ActionWithObject.Delete, User.Identity.GetUserId(), tu.Ten); _tuService.Remove(tu); TempData["AlertMessage"] = "Xóa Thành Công"; return(RedirectToAction("Index")); }