public ActionResult Update(tblCustomerGroup obj) { ViewBag.DDLMenu = (obj != null) ? GetMenuList().Where(n => n.CustomerGroupID != obj.CustomerGroupID.ToString()) : GetMenuList(); var oldObj = _tblCustomerGroupService.GetById(obj.CustomerGroupID); if (oldObj == null) { return(View(obj)); } if (string.IsNullOrWhiteSpace(obj.CustomerGroupName)) { ModelState.AddModelError("CustomerGroupName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["cusGrp_name"]); return(View(oldObj)); } if (!ModelState.IsValid) { return(View(obj)); } oldObj.CustomerGroupCode = obj.CustomerGroupCode; oldObj.CustomerGroupName = obj.CustomerGroupName; oldObj.Description = obj.Description; oldObj.Inactive = obj.Inactive; oldObj.ParentID = obj.ParentID; oldObj.Ordering = obj.Ordering; oldObj.IsCompany = obj.IsCompany; oldObj.Tax = obj.Tax; //Thực hiện cập nhật var result = _tblCustomerGroupService.Update(oldObj); if (result.isSuccess) { WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerGroupID.ToString(), obj.CustomerGroupName, "tblCustomerGroup", ConstField.ParkingCode, ActionConfigO.Update); return(RedirectToAction("Index", new { selectedId = obj.CustomerGroupID })); } else { ModelState.AddModelError("", result.Message); return(View(oldObj)); } }
public ActionResult Update(tblCustomerGroup obj) { ViewBag.DDLMenu = GetMenuList(); if (!ModelState.IsValid) { return(View(obj)); } var oldObj = _tblCustomerGroupService.GetById(obj.CustomerGroupID); if (oldObj == null) { return(View(obj)); } oldObj.CustomerGroupCode = obj.CustomerGroupCode; oldObj.CustomerGroupName = obj.CustomerGroupName; oldObj.Description = obj.Description; oldObj.Inactive = obj.Inactive; oldObj.ParentID = obj.ParentID; oldObj.SortOrder = obj.SortOrder; //Thực hiện cập nhật var result = _tblCustomerGroupService.Update(oldObj); if (result.isSuccess) { WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerGroupID.ToString(), obj.CustomerGroupName, "tblCustomerGroup", ConstField.AccessControlCode, ActionConfigO.Update); return(RedirectToAction("Index", new { selectedId = obj.CustomerGroupID })); } else { ModelState.AddModelError("", result.Message); return(View(oldObj)); } }