Ejemplo n.º 1
0
        public async Task <ActionResult <IGenericReturnModel> > ReturnAllSecrets()
        {
            // Log Requets
            await SqlRequestHandler.LogRequestAsync("GET", HttpContext);

            try
            {
                // Step 2 : Process Database Request
                await SqlRequestHandler.GetAllUserSecretsAsync(HttpContext).ConfigureAwait(false);

                // Step 3: Validate Request Results
                // Validation 1 : Check for Exception Errors
                if (SqlRequestHandler.IsExceptionRaised())
                {
                    return(Conflict(new DatabaseError <Dictionary <string, object> >(
                                        SqlRequestHandler.DictionaryLog,
                                        HttpContext)));
                }

                // Validation 2 : Check for Null Records
                if (SqlRequestHandler.IsRecordsAffected().Equals(false))
                {
                    return(BadRequest(new RecordsNotFound(HttpContext)));
                }

                // Return Results from Database
                return(Ok(new RecordFound <List <Dictionary <string, string> > >(
                              SqlRequestHandler.ToDictionaryList(),
                              HttpContext).ToString()));
            }
            catch (Exception exception)
            {
                return(Conflict(new UnknownError(exception.Message).ToString()));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <IGenericReturnModel> > Return()
        {
            // Log Requets
            await SqlRequestHandler.LogRequestAsync("GET", HttpContext);

            try
            {
                // Step 1: Validate Argument Requirements
                if (!SqlRequestHandler.IsParamsValid(HttpMethod.Get, HttpContext))
                {
                    return(BadRequest(new ArgumentError().ToString()));
                }

                // Step 2 : Process Database Request
                await SqlRequestHandler.GetStoreSecretAsync(
                    EntryTypes.Token,
                    HttpContext);

                // Step 3: Validate Request Results
                // Validation 1 : Check for Exception Errors
                if (SqlRequestHandler.IsExceptionRaised())
                {
                    return(Conflict(new DatabaseError <Dictionary <string, object> >(
                                        SqlRequestHandler.DictionaryLog,
                                        HttpContext)));
                }

                // Validation 2 : Check for Null Records
                if (SqlRequestHandler.IsRecordsAffected().Equals(false))
                {
                    return(BadRequest(new RecordsNotFound(HttpContext)));
                }

                // Return Results from Database
                return(Ok(new RecordFound <Dictionary <string, string> >(
                              SqlRequestHandler.ToDictionary(),
                              HttpContext).ToString()));
            }
            catch (Exception exception)
            {
                return(Conflict(new UnknownError(exception.Message).ToString()));
            }
        }