public ValidationFailure CreateRoleConfigurationValidate(RoleConfiguration roleConfiguration, ValidationContext <RoleConfiguration> context)
        {
            var roleConfigurationRetrieve = _roleConfigurationRepository.FindBy(roleConfig => roleConfig.RoleId == roleConfiguration.RoleId && roleConfig.PermissionId == roleConfiguration.PermissionId && roleConfig.AccessLevelId == roleConfiguration.AccessLevelId);

            if (roleConfigurationRetrieve.IsNotEmpty())
            {
                return(new ValidationFailure("RoleConfiguration", string.Format("Ya existe la configuración {0}, {1}, {2}", roleConfiguration.RoleId, roleConfiguration.PermissionId, roleConfiguration.AccessLevelId)));
            }
            return(null);
        }
Ejemplo n.º 2
0
 public SuccessResponse Update(RoleConfigurationRequest request)
 {
     try
     {
         var currentRoleConfiguration = _roleConfigurationRepository.FindBy(request.Id);
         currentRoleConfiguration.ThrowExceptionIfRecordIsNull();
         var roleConfigurstionToCopy = TypeAdapter.Adapt <RoleConfiguration>(request);
         TypeAdapter.Adapt(roleConfigurstionToCopy, currentRoleConfiguration);
         _roleConfigurationValidator.ValidateAndThrowException(currentRoleConfiguration, "Base,Update");
         _roleConfigurationRepository.Update(currentRoleConfiguration);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }