Ejemplo n.º 1
0
        private string ValidateCurrentUsageAndLimitationsForCurrentUserModel(GetCurrentUsageAndLimitationsForCurrentUserModel validationObj)
        {
            ValidationResult validationResult = new SessionCodeValidator(validationObj.SessionCode).Validate();

            if (!validationResult.IsValid)
            {
                _messageBuilder.AppendLine(validationResult.Message);
            }
            return(_messageBuilder.ToString());
        }
Ejemplo n.º 2
0
        public override ValidationResult Validate()
        {
            string message = _validationObject switch
            {
                AuthenticateUserOpenIdModel model => ValidateAuthenticateUserOpenIdModel(model),
                AuthenticateUserPasswordModel model => ValidateAuthenticateUserPasswordModel(model),
                AuthenticateUserDigitalSignatureModel model => ValidateAuthenticateUserDigitalSignatureModel(model),
                GetCurrentUsageAndLimitationsForCurrentUserModel model => ValidateCurrentUsageAndLimitationsForCurrentUserModel(model),
                _ => string.Empty
            };

            return(new ValidationResult(string.IsNullOrEmpty(message), message));
        }
Ejemplo n.º 3
0
        public IActionResult GetCurrentUsageAndLimitationsForCurrentUser(GetCurrentUsageAndLimitationsForCurrentUserModel model)
        {
            try
            {
                _logger.LogDebug($"Endpoint: \"UserAndLimitationManagement\" Method: \"GetCurrentUsageAndLimitationsForCurrentUser\" Parameters: \"{model}\"");
                ValidationResult validationResult = new UserAndLimitationManagementValidator(model).Validate();
                if (!validationResult.IsValid)
                {
                    ExceptionHandler.ThrowProperExternalException(new InputValidationException(validationResult.Message));
                }

                return(Ok(_service.GetCurrentUsageAndLimitationsForCurrentUser(model.SessionCode)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }