Exemplo n.º 1
0
        public CreatedResult GetError500_InternalServerError(string transactionID, string errorMessage, string errorInternal, string route)
        {
            /*General_500ErrorResponse general_500ErrorResponse = new General_500ErrorResponse();
             * general_500ErrorResponse.TransactionID = transactionID;
             * general_500ErrorResponse.Error = errorMessage;
             * general_500ErrorResponse.Route = route;
             * general_500ErrorResponse.ErrorInternal = null;
             *
             * GeneralErrorResponseContainer generalErrorResponseContainer = new GeneralErrorResponseContainer();
             * generalErrorResponseContainer.Warning = System.Net.HttpStatusCode.InternalServerError.ToString();
             * generalErrorResponseContainer.ErrorResponse = general_500ErrorResponse;
             * CreatedResult createdResult = new CreatedResult(route, null);
             * createdResult.StatusCode = 500;
             * createdResult.Value = generalErrorResponseContainer;
             * return createdResult;*/

            GeneralErrorResponse general_500ErrorResponse = new GeneralErrorResponse();

            general_500ErrorResponse.TransactionID = transactionID;
            general_500ErrorResponse.Error         = errorMessage;
            general_500ErrorResponse.Route         = route;
            general_500ErrorResponse.ErrorInternal = errorInternal;
            GeneralErrorResponseContainer generalErrorResponseContainer = new GeneralErrorResponseContainer();

            generalErrorResponseContainer.Warning       = System.Net.HttpStatusCode.PreconditionFailed.ToString();
            generalErrorResponseContainer.ErrorResponse = general_500ErrorResponse;
            CreatedResult createdResult = new CreatedResult(route, null);

            createdResult.StatusCode = 412;
            createdResult.Value      = generalErrorResponseContainer;
            return(createdResult);
        }
Exemplo n.º 2
0
        public CreatedResult GetError412_PreConditionFailed(string transactionID, string errorMessage, string errorInternal, string route)
        {
            GeneralErrorResponse general_412ErrorResponse = new GeneralErrorResponse();

            general_412ErrorResponse.TransactionID = transactionID;
            general_412ErrorResponse.Error         = errorMessage;
            general_412ErrorResponse.Route         = route;
            general_412ErrorResponse.ErrorInternal = errorInternal;
            GeneralErrorResponseContainer generalErrorResponseContainer = new GeneralErrorResponseContainer();

            generalErrorResponseContainer.Warning       = System.Net.HttpStatusCode.PreconditionFailed.ToString();
            generalErrorResponseContainer.ErrorResponse = general_412ErrorResponse;
            CreatedResult createdResult = new CreatedResult(route, null);

            createdResult.StatusCode = 412;
            createdResult.Value      = generalErrorResponseContainer;
            return(createdResult);
        }
Exemplo n.º 3
0
 public NotFoundException(GeneralErrorResponse response)
     : base(response.mesaj)
 {
     this.response = response;
 }
        /**
         * Set user email.
         */
        internal async Task <APIGatewayProxyResponse> SetUserEmail(IDataStores dataStores,
                                                                   IDictionary <string, string> requestHeaders,
                                                                   JObject requestBody)
        {
            Debug.Untested();
            Debug.AssertValid(dataStores);
            Debug.AssertValid(requestHeaders);
            Debug.AssertValidOrNull(requestBody);

            try {
                // Log call
                LoggingHelper.LogMessage($"UserIdentityService::SetUserEmail()");

                // Get the NoSQL DB client
                AmazonDynamoDBClient dbClient = (AmazonDynamoDBClient)dataStores.GetNoSQLDataStore().GetDBClient();
                Debug.AssertValid(dbClient);

                // Check inputs
                SetUserEmailRequest setUserEmailRequest = UserIdentityService_SetUserEmail_LogicLayer.CheckValidSetUserEmailRequest(requestBody);
                Debug.AssertValid(setUserEmailRequest);

                // Check authenticated endpoint security
                string loggedInUserId = await APIHelper.CheckLoggedIn(dbClient, requestHeaders);

                Debug.AssertID(loggedInUserId);

                // Perform logic
                await UserIdentityService_SetUserEmail_LogicLayer.SetUserEmail(dbClient, loggedInUserId, setUserEmailRequest);

                // Respond
                return(new APIGatewayProxyResponse {
                    StatusCode = APIHelper.STATUS_CODE_NO_CONTENT
                });
            } catch (Exception exception) {
                Debug.Tested();
                if ((exception.Message == IdentityServiceLogicLayer.ERROR_EMAIL_IN_USE) ||
                    (exception.Message == IdentityServiceLogicLayer.ERROR_EMAIL_ALREADY_BEING_CHANGED))
                {
                    Debug.Untested();
                    GeneralErrorResponse response = new GeneralErrorResponse();
                    if (exception.Message == IdentityServiceLogicLayer.ERROR_EMAIL_IN_USE)
                    {
                        Debug.Untested();
                        response.error = IdentityServiceLogicLayer.EMAIL_IN_USE;
                    }
                    else if (exception.Message == IdentityServiceLogicLayer.ERROR_EMAIL_ALREADY_BEING_CHANGED)
                    {
                        Debug.Untested();
                        response.error = IdentityServiceLogicLayer.EMAIL_ALREADY_BEING_CHANGED;
                    }
                    //??--ObjectResult result = new ObjectResult(response);
                    //??--result.StatusCode = APIHelper.STATUS_CODE_UNAUTHORIZED;
                    //??--return StatusCode(APIHelper.STATUS_CODE_UNAUTHORIZED, response);
                    return(new APIGatewayProxyResponse {
                        StatusCode = APIHelper.STATUS_CODE_UNAUTHORIZED,
                        Body = JsonConvert.SerializeObject(response)
                    });
                }
                else
                {
                    Debug.Tested();
                    return(APIHelper.ResponseFromException(exception));
                }
            }
        }
 public BadRequestException(GeneralErrorResponse response)
     : base(response.mesaj)
 {
     this.response = response;
 }
Exemplo n.º 6
0
 public UnauthorizedException(GeneralErrorResponse response)
     : base(response.mesaj)
 {
     this.response = response;
 }