public IActionResult ManageRole(Int64?id) { US_ROLE _obj = new US_ROLE(); if (id != null) { _obj = _unitOfWork.US_ROLE.Get(id.Value); if (_obj == null) { TempData["msg"] = SweetMsg.SaveWarningOK(); } } return(View(_obj)); }
public IActionResult ManageRole(US_ROLE _obj) { if (ModelState.IsValid) { if (_obj.ID == 0) { _obj.ID = _unitOfWork.US_ROLE.GetAll().Max(x => x.ID) + 1; _obj.IS_ACTIVE = true; _unitOfWork.US_ROLE.Add(_obj); } else { _unitOfWork.US_ROLE.Update(_obj); } _unitOfWork.Save(); TempData["msg"] = SweetMsg.SaveSuccess(); return(RedirectToAction(nameof(ManageRole))); } TempData["msg"] = SweetMsg.SaveErrorOK(); _obj.ID = 0; return(View(_obj)); }