Exemplo n.º 1
0
 public async Task <LoginResponse> Post([FromBody] LoginRequest request)
 {
     try
     {
         ContextFactory.Current.Logger.StartMethodWithRequest <LoginRequest>(request.RequestID.ToString(), nameof(Post), request);
         return(await request.ValidateUser());
     }
     catch (AcubecException e)
     {
         ContextFactory.Current.Logger.ExceptionCaught(request.RequestID.ToString(), nameof(Post), $"exception with Code{e.ExceptionCode}", e);
         return(new LoginResponse()
         {
             ErrorCode = e.ExceptionCode.ToString(),
             ErrorMessage = ErrorConstnts.ManageMessage(e.ExceptionCode.ToString())
         });
     }
     catch (Exception ex)
     {
         ContextFactory.Current.Logger.ExceptionCaught(request.RequestID.ToString(), nameof(Post), "Generic exception", ex);
         return(new LoginResponse()
         {
             ErrorCode = ErrorConstnts.GenericErrorCode.ToString(),
             ErrorMessage = ErrorConstnts.ManageMessage(ErrorConstnts.GenericErrorCode)
         });
     }
 }
Exemplo n.º 2
0
        public static async Task <LoginResponse> CreateUser(this LoginRequest loginRequest)
        {
            try
            {
                loginRequest.CheckRequestId();
                var response = await APIHelper.HttpClientPostAsync <LoginResponse, LoginRequest>(loginRequest.RequestID.ToString()
                                                                                                 , "SecurityFactory", "Validator/Validate", loginRequest);

                return(response);
            }
            catch (AcubecException e)
            {
                ContextFactory.Current.Logger.ExceptionCaught(loginRequest.RequestID.ToString(), nameof(ValidateUser), $"exception with Code{e.ExceptionCode}", e);
                return(new LoginResponse()
                {
                    ErrorCode = e.ExceptionCode.ToString(),
                    ErrorMessage = ErrorConstnts.ManageMessage(e.ExceptionCode.ToString()),
                });
            }
            catch (Exception ex)
            {
                ContextFactory.Current.Logger.ExceptionCaught(loginRequest.RequestID.ToString(), nameof(ValidateUser), $"exception with Code 396", ex);
                return(new LoginResponse()
                {
                    ErrorCode = "396",
                    ErrorMessage = ErrorConstnts.ManageMessage(ErrorConstnts.GenericErrorCode)
                });
            }
        }