public ValidationFailure ReferencesValidate(RoleConfiguration roleConfiguration, ValidationContext <RoleConfiguration> context) { var role = _roleRepository.FindBy(roleConfiguration.RoleId); if (role.IsNull()) { return(new ValidationFailure("RoleConfiguration", "El rol no existe")); } var permission = _permissionRepository.FindBy(roleConfiguration.PermissionId); if (permission.IsNull()) { return(new ValidationFailure("RoleConfiguration", "El permiso no existe")); } var accessLevel = _accessLevelRepository.FindBy(roleConfiguration.AccessLevelId); if (accessLevel.IsNull()) { return(new ValidationFailure("RoleConfiguration", "El nivel de acceso no existe")); } return(null); }
public DTO.RoleConfiguration Execute(RoleConfiguration roleConfiguration) { var roleConfigurationDto = TypeAdapter.Adapt <DTO.RoleConfiguration>(roleConfiguration); var role = _roleRepository.FindBy(roleConfiguration.RoleId); roleConfigurationDto.Role = TypeAdapter.Adapt <DTO.Role>(role); var permission = _permissionRepository.FindBy(roleConfiguration.PermissionId); roleConfigurationDto.Permission = TypeAdapter.Adapt <DTO.Permission>(permission); var accessLevel = _accessLevelRepository.FindBy(roleConfiguration.AccessLevelId); roleConfigurationDto.AccessLevel = TypeAdapter.Adapt <DTO.AccessLevel>(accessLevel); return(roleConfigurationDto); }