Ejemplo n.º 1
0
        public async Task <IActionResult> InputPartial(EntityId <int> idModel, string group = null)
        {
            // init input model
            MasterListInput input = masterListAdminService.GetInputById(idModel);

            if (input == null)
            {
                if (!HasPermission(ConstantConfig.Claims.MasterListManagement_AddMasterList))
                {
                    return(Forbid());
                }
                input = new MasterListInput();
            }
            else
            {
                if (!HasPermission(ConstantConfig.Claims.MasterListManagement_ActionButton_UpdateMasterList))
                {
                    return(Forbid());
                }
            }
            input.Group = group;
            // init combobox
            ViewBag.PermissionCombobox = await permissionService.GetPermissionCombobox();

            return(PartialView(input));
        }
Ejemplo n.º 2
0
        public MasterListInput Add(MasterListInput inputModel)
        {
            var entity = mapper.Map <MasterList>(inputModel);

            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 <MasterListInput>(entity));
        }
Ejemplo n.º 3
0
        public bool Update(MasterListInput inputModel)
        {
            var entity = GetById(inputModel);

            if (entity == null)
            {
                return(false);
            }
            mapper.Map(inputModel, entity);
            entity.ModifiedDate = DateTime.Now;
            entity.ModifiedBy   = GetCurrentUserLogin();
            entity.UpdateToken  = Guid.NewGuid();
            masterListRepository.Update(entity);
            return(true);
        }
Ejemplo n.º 4
0
 public IActionResult InputPartial([Required] MasterListInput inputModel)
 {
     try
     {
         MasterList lastInfo = masterListAdminService.GetById(inputModel);
         if (lastInfo != null)
         {
             // update
             if (!HasPermission(ConstantConfig.Claims.MasterListManagement_ActionButton_UpdateMasterList))
             {
                 return(Forbid());
             }
             if (lastInfo.UpdateToken.GetValueOrDefault(Guid.Empty).Equals(inputModel.UpdateToken))
             {
                 masterListAdminService.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());
             }
             MasterListInput result = masterListAdminService.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) }));
     }
 }