public IActionResult OpenForm(int?id) { var entity = new OrderTrackAction(); if (id != null) { //Check User Permission For this Page if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.OrderTrackAction, EN_Permissions.Edit)) { return(Redirect("/Home")); } entity = _uow.OrderTrackActionRepository.GetById(id); if (entity == null || entity.IsDeleted) { return(NotFound()); } } else { //Check User Permission For this Page if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.OrderTrackAction, EN_Permissions.Create)) { return(Redirect("/Home")); } } return(View(entity)); }
public IActionResult Save(OrderTrackAction entity) { string strReturnMsg = "error"; try { if (entity.Id == default) { entity.Code = UIHelper.GeneratCode(EN_Screens.OrderTrackAction, _uow); if (string.IsNullOrEmpty(entity.ArabicName)) { entity.ArabicName = entity.ArabicName; } entity.CreationDate = DateTime.Now; entity.CreatedBy = AppSession.CurrentUser.Id; //Re-ValidateModel ModelState.Clear(); TryValidateModel(entity); if (ModelState.IsValid) { _uow.OrderTrackActionRepository.Add(entity); } } else { entity.ModificationDate = DateTime.Now; entity.ModifiedBy = AppSession.CurrentUser.Id; //Re-ValidateModel ModelState.Clear(); TryValidateModel(entity); if (ModelState.IsValid) { _uow.OrderTrackActionRepository.Update(entity); } } _uow.Save(); strReturnMsg = "success"; } catch (Exception ex) { } return(Json(new { id = entity.Id, status = strReturnMsg })); }