public async Task <IActionResult> InputPartial(EntityId <int> idModel) { // init input model MasterListGroupInput input = masterListGroupAdminService.GetInputById(idModel); if (input == null) { if (!HasPermission(ConstantConfig.Claims.MasterListManagement_AddMasterList)) { return(Forbid()); } input = new MasterListGroupInput(); } else { if (!HasPermission(ConstantConfig.Claims.MasterListManagement_ActionButton_UpdateMasterList)) { return(Forbid()); } } // init combobox ViewBag.PermissionCombobox = await permissionService.GetPermissionCombobox(); return(PartialView(input)); }
public MasterListGroupInput Add(MasterListGroupInput inputModel) { MasterList entity = mapper.Map <MasterList>(inputModel); entity.Group = ConstantConfig.MasterListMasterGroup; entity.CreatedBy = GetCurrentUserLogin(); entity.CreatedDate = DateTime.Now; entity.ModifiedDate = DateTime.Now; entity.ModifiedBy = GetCurrentUserLogin(); entity.RecordStatus = ConstantConfig.RecordStatusConfig.Active; entity.UpdateToken = Guid.NewGuid(); masterListRepository.Add(entity); return(mapper.Map <MasterListGroupInput>(entity)); }
public bool Update(MasterListGroupInput inputModel) { MasterList entity = GetById(inputModel); if (entity == null) { return(false); } mapper.Map(inputModel, entity); entity.Group = ConstantConfig.MasterListMasterGroup; entity.ModifiedDate = DateTime.Now; entity.ModifiedBy = GetCurrentUserLogin(); entity.UpdateToken = Guid.NewGuid(); masterListRepository.Update(entity); return(true); }
public IActionResult InputPartial([Required] MasterListGroupInput inputModel) { try { MasterList lastInfo = masterListGroupAdminService.GetById(inputModel); if (lastInfo != null) { // update if (!HasPermission(ConstantConfig.Claims.MasterListManagement_ActionButton_UpdateMasterList)) { return(Forbid()); } if (lastInfo.UpdateToken.GetValueOrDefault(Guid.Empty).Equals(inputModel.UpdateToken)) { masterListGroupAdminService.Update(inputModel); unitOfWork.SaveChanges(); return(Ok(new { result = ConstantConfig.WebApiStatusCode.Success, message = GetLang(ConstantConfig.WebApiResultMessage.UpdateSuccess) })); } return(Ok(new { result = ConstantConfig.WebApiStatusCode.Warning, message = GetLang(ConstantConfig.WebApiResultMessage.UpdateTokenNotMatch) })); } else { // insert if (!HasPermission(ConstantConfig.Claims.MasterListManagement_AddMasterList)) { return(Forbid()); } MasterListGroupInput result = masterListGroupAdminService.Add(inputModel); if (result == null) { return(Ok(new { result = ConstantConfig.WebApiStatusCode.Error, message = GetLang(ConstantConfig.WebApiResultMessage.Error) })); } unitOfWork.SaveChanges(); return(Ok(new { result = ConstantConfig.WebApiStatusCode.Success, message = GetLang(ConstantConfig.WebApiResultMessage.UpdateSuccess) })); } } catch { return(Ok(new { result = ConstantConfig.WebApiStatusCode.Error, message = GetLang(ConstantConfig.WebApiResultMessage.Error) })); } }