/// <summary> /// Inserts the raid ticks /// </summary> /// <param name="pDBContext">The database context to insert the raid ticks to</param> /// <param name="pModel">The raid model containing the Ticks</param> /// <param name="pCharacterModels">The character models should already be prepopulated and passed in</param> public static void InsertRaidTicks(opendkpContext pDBContext, string pClientId, dynamic pModel, Dictionary <string, Characters> pCharacterModels) { //Insert each Tick and Add Raid Attendees foreach (var vModelTick in pModel.Ticks) { Ticks vTick = new Ticks() { Description = vModelTick.Description, Value = vModelTick.Value, RaidId = pModel.IdRaid, ClientId = pClientId }; pDBContext.Add(vTick); //Make sure we don't have duplicate attendees for each tick //client should handle this but we'll verify here string[] vAttendeeArray = vModelTick.Attendees.ToObject <string[]>(); vAttendeeArray = vAttendeeArray.Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); //Add Attendees to Tick foreach (string vAttendee in vAttendeeArray) { pDBContext.Add( new TicksXCharacters() { IdCharacterNavigation = pCharacterModels[vAttendee.ToLower()], IdTickNavigation = vTick, ClientId = pClientId }); } } }
private APIGatewayProxyResponse HandleInsert(APIGatewayProxyRequest pRequest, ILambdaContext pContext, CognitoUser pCognitoUser, opendkpContext pDatabase, string pClientId) { var vResponse = HttpHelper.HandleError("[Insert] Unknown error backend...", 500); try { Characters vModel = JsonConvert.DeserializeObject <Characters>(pRequest.Body); if (vModel != null) { Characters vExists = pDatabase.Characters.FirstOrDefault(x => x.ClientId.Equals(pClientId) && x.Name.Equals(vModel.Name, StringComparison.InvariantCultureIgnoreCase)); if (vExists != null && vExists.IdCharacter >= 0) { vResponse = HttpHelper.HandleError("Character found in database, can't duplicate. Character Name must be unique", 500); } else { //Enforce ClientId serverside, don't trust what the client sends us vModel.ClientId = pClientId; pDatabase.Add(vModel); pDatabase.SaveChanges(); AuditHelper.InsertAudit(pDatabase, pClientId, string.Empty, vModel, pCognitoUser.Username, Audit.ACTION_CHAR_INSERT); vResponse = HttpHelper.HandleResponse(vModel, 200, true); } } } catch (Exception vException) { vResponse = HttpHelper.HandleError(vException.Message, 500); } return(vResponse); }
/// <summary> /// As the name suggests, creates a character if they are needed. Need is determined by whether or not they already exist in the database /// </summary> /// <param name="pDBContext">The database context to search for the character</param> /// <param name="pCharacterName">The character name to search for, case-insensitive</param> /// <returns></returns> public static Characters CreateCharacterIfNeeded(opendkpContext pDBContext, string pClientId, string pCharacterName) { Characters vCharacterModel = pDBContext.Characters .FirstOrDefault(x => x.Name.Equals(pCharacterName, StringComparison.InvariantCultureIgnoreCase)); //If the character doesn't exist, we need to create a blank one first if (vCharacterModel == null) { vCharacterModel = new Characters { Name = char.ToUpper(pCharacterName[0]) + pCharacterName.Substring(1), Class = "UNKNOWN", Race = "UNKNOWN", Active = 1, Rank = "Inactive", Level = 1, Gender = "Male", Guild = "Original Gangster Club", ClientId = pClientId }; pDBContext.Add(vCharacterModel); pDBContext.SaveChanges(); } return(vCharacterModel); }
/// <summary> /// Creates an item into the db if needed (not found already) /// </summary> /// <param name="pDBContext">The database context in which to look or create the item in</param> /// <param name="pItem">The item to create or lookup, checks for its Id first otherwise by name</param> /// <returns></returns> public static Items CreateItemIfNeeded(opendkpContext pDBContext, Items pItem) { Items vFoundItem = pDBContext.Items.FirstOrDefault <Items>(x => x.IdItem == pItem.IdItem); //If we don't find the item by it's ID if (vFoundItem == null) { vFoundItem = pDBContext.Items .FirstOrDefault <Items>(x => x.Name.Trim().Equals(pItem.Name.Trim(), StringComparison.InvariantCultureIgnoreCase)); //If we don't find the item by it's name if (vFoundItem == null) { var vNewItem = new Items { Name = pItem.Name }; pDBContext.Add(vNewItem); pDBContext.SaveChanges(); vFoundItem = vNewItem; } } return(vFoundItem); }
/// <summary> /// Set the cache value for a particular cache /// </summary> /// <param name="pContext">The database context in which to set the cache in</param> /// <param name="pCacheName">The name of the cache you are storing, case-insensitive</param> /// <param name="pCacheValue">The value to be stored for this cache</param> /// <param name="pCacheExpires">The time the cache should expire</param> public static void SetCache(opendkpContext pContext, string pCacheName, string pCacheValue, string pClientId, DateTime?pCacheExpires = null) { if (pCacheExpires == null) { pCacheExpires = DateTime.Now.AddHours(12); } try { Cache vCachedSummary = pContext.Cache.FirstOrDefault(x => x.ClientId.Equals(pClientId) && x.CacheName.Equals(pCacheName, StringComparison.InvariantCultureIgnoreCase)); if (vCachedSummary == null) { vCachedSummary = new Cache { CacheName = pCacheName, ClientId = pClientId }; pContext.Add <Cache>(vCachedSummary); } vCachedSummary.CacheUpdated = DateTime.Now; vCachedSummary.CacheExpires = DateTime.Now.AddHours(12); vCachedSummary.CacheValue = pCacheValue; pContext.SaveChanges(); } catch (Exception vException) { Console.WriteLine("Error Cacheing: " + vException); } }
/// <summary> /// Inserts the raid items into the database associated with the raid passed in /// </summary> /// <param name="pDBContext">The database context to insert items to</param> /// <param name="pModel">The raid model containing the items</param> /// <param name="pCharacterModels">A pre-populated character list so we dont have to look them all up on the fly</param> public static void InsertRaidItems(opendkpContext pDBContext, string pClientId, dynamic pModel, Dictionary <string, Characters> pCharacterModels) { //Lets insert the items from this raid foreach (var vItem in pModel.Items) { string vCharName = vItem.CharacterName; Items vNewItem; if (vItem.ItemID != null) { vNewItem = new Items() { IdItem = vItem.ItemID, Name = vItem.ItemName } } ; else { vNewItem = new Items() { IdItem = -1, Name = vItem.ItemName } }; vNewItem = ItemHelper.CreateItemIfNeeded(pDBContext, vNewItem); ItemsXCharacters vTransaction = new ItemsXCharacters() { Dkp = vItem.DkpValue, CharacterId = pCharacterModels[vCharName.ToLower()].IdCharacter, ItemId = vNewItem.IdItem, RaidId = pModel.IdRaid, ClientId = pClientId }; pDBContext.Add(vTransaction); } }
private APIGatewayProxyResponse HandleInsert(APIGatewayProxyRequest pRequest, ILambdaContext pContext, CognitoUser pCognitoUser, opendkpContext pDatabase) { var vResponse = HttpHelper.HandleError("[InsertOrUpdateAdjustment] Unknown error backend...", 500); //We need to retrieve the ClientId for multitenancy purposes var vClientId = pRequest.Headers["clientid"]; try { //Populate Model dynamic vModel = JsonConvert.DeserializeObject(pRequest.Body); string vInputCharacters = (string)vModel.Character; vInputCharacters = vInputCharacters.Trim(); string[] vCharacterList = vInputCharacters.Split(','); using (var dbContextTransaction = pDatabase.Database.BeginTransaction()) { foreach (string vCharacter in vCharacterList) { //Create our Adjustment for each Character Adjustments vAdjustment = new Adjustments { Name = vModel.Name, Description = vModel.Description, Value = vModel.Value, Timestamp = vModel.Timestamp, ClientId = vClientId }; //Convert Character Name to Character Id vAdjustment.IdCharacter = DkpConverters.CharacterNameToId(pDatabase, vClientId, vCharacter); if (vAdjustment != null && vAdjustment.IdCharacter > -1) { pDatabase.Add(vAdjustment); pDatabase.SaveChanges(); } } //Commit changes to DB dbContextTransaction.Commit(); //Create success response vResponse = HttpHelper.HandleResponse(vModel, 200); //Audit AuditHelper.InsertAudit(pDatabase, vClientId, string.Empty, vModel, pCognitoUser.Username, Audit.ACTION_ADJUST_INSERT); //Update Caches int vStatus = CacheManager.UpdateSummaryCacheAsync(vClientId).GetAwaiter().GetResult(); Console.WriteLine("StatusCode for CacheUpdate=" + vStatus); } } catch (Exception vException) { vResponse = HttpHelper.HandleError(vException.Message, 500); } return(vResponse); }
private APIGatewayProxyResponse UpdateCharacterAssignRequest(opendkpContext pDatabase, string pClientId, UserRequests pUserRequest, CognitoUser pCognitoUser) { var vResponse = HttpHelper.HandleError("[UserRequestsLambda] Issue with DB or Query", 500); if (!string.IsNullOrWhiteSpace(pUserRequest.Requestor) && !string.IsNullOrWhiteSpace(pUserRequest.RequestDetails)) { if (pUserRequest.RequestStatus == UserRequests.STATUS_APPROVED) { dynamic vCharacterId = JsonConvert.DeserializeObject(pUserRequest.RequestDetails); int vId = vCharacterId.characterId; //I need to associate the character //If character associate is successful, I need to update pending request to completed using (var dbContextTransaction = pDatabase.Database.BeginTransaction()) { UserXCharacter vAssociation = new UserXCharacter(); vAssociation.User = pUserRequest.Requestor; vAssociation.IdCharacter = vId; vAssociation.ApprovedBy = pCognitoUser.Username; vAssociation.ClientId = pClientId; pDatabase.Add(vAssociation); UserRequests vRequest = pDatabase.UserRequests.FirstOrDefault(x => x.ClientId.Equals(pClientId) && x.Id == pUserRequest.Id); if (vRequest == null) { return(HttpHelper.HandleError("[UserRequestsLambda] Couldn't find the Request in DB to update...", 500)); } vRequest.RequestApprover = pCognitoUser.Username; vRequest.ReviewedTimestamp = DateTime.Now; vRequest.RequestStatus = UserRequests.STATUS_APPROVED; vRequest.ClientId = pClientId; pDatabase.SaveChanges(); dbContextTransaction.Commit(); vResponse = HttpHelper.HandleResponse(vRequest, 200, true); } } else if (pUserRequest.RequestStatus == UserRequests.STATUS_DENIED) { UserRequests vRequest = pDatabase.UserRequests.FirstOrDefault(x => x.ClientId.Equals(pClientId) && x.Id == pUserRequest.Id); if (vRequest == null) { return(HttpHelper.HandleError("[UserRequestsLambda] Couldn't find the Request in DB to update...", 500)); } vRequest.RequestApprover = pCognitoUser.Username; vRequest.ReviewedTimestamp = DateTime.Now; vRequest.RequestStatus = UserRequests.STATUS_DENIED; vRequest.RequestDetails = pUserRequest.RequestDetails; vRequest.ClientId = pClientId; pDatabase.SaveChanges(); vResponse = HttpHelper.HandleResponse(vRequest, 200, true); } } return(vResponse); }
/// <summary> /// Inserts a UserRequest to the database /// </summary> /// <param name="pDBContext">The database context</param> /// <param name="pRequest">The user request</param> /// <returns></returns> public static bool InsertRequest(opendkpContext pDBContext, UserRequests pRequest) { bool vReturn = false; try { pDBContext.Add(pRequest); pDBContext.SaveChanges(); vReturn = true; } catch (Exception vException) { Console.WriteLine("Error Inserting AdminRequest: " + vException); } return(vReturn); }
private APIGatewayProxyResponse HandleCharacterAssignRequest(opendkpContext pDatabase, UserRequests pUserRequest, APIGatewayProxyRequest pRequest, CognitoUser pCognitoUser) { var vResponse = HttpHelper.HandleError("[UserRequestsLambda] Issue with DB or Query", 500); //We need to retrieve the ClientId for multitenancy purposes var vClientId = pRequest.Headers["clientid"]; if (!string.IsNullOrWhiteSpace(pUserRequest.RequestDetails)) { dynamic vCharacterId = JsonConvert.DeserializeObject(pUserRequest.RequestDetails); int vId = vCharacterId.characterId; //Determine if we've already got a character associated for this character Id var vFound = pDatabase.UserXCharacter.FirstOrDefault(x => x.ClientId.Equals(vClientId) && x.IdCharacter == vId); if (vFound != null) { return(HttpHelper.HandleError("[UserRequestsLambda] This character has already been associated to an account", 500)); } //Verify that there is not already an open pending request for the specific character //Note: It's possible someone else tries to claim someone elses character and this request would block them //TODO: Review note above, determine if anything should be done regarding this scenario var vPendingRequests = pDatabase.UserRequests.Where(x => x.ClientId.Equals(vClientId) && x.RequestType == UserRequests.TYPE_CHARACTER_ASSIGN && x.RequestStatus == UserRequests.STATUS_PENDING).ToList(); foreach (var vRequest in vPendingRequests) { dynamic vTmpCharId = JsonConvert.DeserializeObject(vRequest.RequestDetails); int vTmpId = vTmpCharId.characterId; if (vTmpId == vId) { return(HttpHelper.HandleError("[UserRequestsLambda] There is already a pending request for this character", 500)); } } pUserRequest.Requestor = pCognitoUser.Username; pUserRequest.RequestStatus = UserRequests.STATUS_PENDING; pUserRequest.RequestTimestamp = DateTime.Now; pUserRequest.RequestApprover = "NONE"; pUserRequest.ReviewedTimestamp = DateTime.Now; pUserRequest.ClientId = vClientId; pDatabase.Add(pUserRequest); pDatabase.SaveChanges(); vResponse = HttpHelper.HandleResponse(pUserRequest, 200, true); } return(vResponse); }
/// <summary> /// Creates a raid Id, probably isn't needed anymore but early on in development I needed to get the RaidID first. 99.99% sure this isn't needed anymore but no time to refactor /// </summary> /// <param name="pDBContext">The database context to create the raid id in</param> /// <param name="pModel">The model containing the raid information to generate the id</param> /// <returns></returns> public static int CreateRaidId(opendkpContext pDBContext, string pClientId, dynamic pModel) { //Insert the raid first to get the RaidId Raids vRaid = new Raids() { Name = pModel.Name, Timestamp = pModel.Timestamp, IdPool = pModel.Pool.IdPool, UpdatedBy = pModel.UpdatedBy, UpdatedTimestamp = pModel.UpdatedTimestamp, ClientId = pClientId }; pDBContext.Add(vRaid); pDBContext.SaveChanges(); //Set Raid Id to the Model we return to client for future updates return(vRaid.IdRaid); }
/// <summary> /// Insert an audit entry into the audit table. This function will store the text passed in /// </summary> /// <param name="pDBContext">The database context to which the audit will be stored</param> /// <param name="pOldModel">A string representing an old value (changed from)</param> /// <param name="pNewModel">A string representing a new value (changed to)</param> /// <param name="pUsername">The username who made the change</param> /// <param name="pAction">The action being performed</param> public static void InsertAudit(opendkpContext pDBContext, string pClientId, string pOldModel, string pNewModel, string pUsername, string pAction) { try { Audit vAudit = new Audit { OldValue = pOldModel, NewValue = pNewModel, Timestamp = DateTime.Now, CognitoUser = pUsername, Action = pAction, ClientId = pClientId }; pDBContext.Add(vAudit); pDBContext.SaveChanges(); } catch (Exception vException) { Console.WriteLine("Failed to log audit for some reason"); Console.WriteLine(vException); } }
/// <summary> /// /// </summary> /// <param name="pRequest">Incoming API Gateway request object, not used currently</param> /// <param name="pContext">Incoming Lambda Context object, not used currently</param> /// <returns></returns> public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest pRequest, ILambdaContext pContext) { if (pRequest.Headers != null && pRequest.Headers.Count > 0 && pRequest.Headers.Keys.Contains("warmup")) { return(HttpHelper.WarmupResponse()); } var vResponse = HttpHelper.HandleError("[AdminSettings] Unknown Error in backend", 500); //We need to retrieve the ClientId for multitenancy purposes var vClientId = pRequest.Headers["clientid"]; try { using (opendkpContext vDatabase = new opendkpContext()) { if (pRequest.HttpMethod == "GET") { string vSettingName = pRequest.PathParameters["setting"]; var vResult = vDatabase.AdminSettings.Where(x => x.ClientId.Equals(vClientId) && x.SettingName.Equals(vSettingName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (vResult == null) { vResult = new AdminSettings(); } return(HttpHelper.HandleResponse(JsonConvert.SerializeObject(vResult), 200)); } //This is the Guild Dump Utility I quickly wrote if (pRequest.HttpMethod == "POST") { //Authorize User for POST requests only if (!CognitoHelper.IsDkpAdmin(pRequest) || !CognitoHelper.IsAuthorizedAdmin(vDatabase, pRequest)) { return(HttpHelper.HandleError("You do not have permission to perform this action", 401)); } //Process Guild Dump dynamic vModel = JsonConvert.DeserializeObject(pRequest.Body); string vAction = vModel.Action; JArray vData = vModel.Data; if (!string.IsNullOrWhiteSpace(vAction)) { var vCharacters = vData.ToObject <Characters[]>(); List <string> vCharacterNames = new List <string>(); foreach (Characters vCharacter in vCharacters) { vCharacterNames.Add(vCharacter.Name); } var vResults = vDatabase.Characters.Where(x => x.ClientId.Equals(vClientId) && vCharacterNames.Contains(x.Name)); foreach (var item in vResults) { var vChar = vCharacters.FirstOrDefault(x => x.Name.Equals(item.Name)); if (vChar != null) { item.Level = vChar.Level; item.Rank = vChar.Rank; item.Class = vChar.Class; } } vDatabase.SaveChanges(); return(HttpHelper.HandleResponse("Success", 200)); } else { AdminSettings vInputModel = JsonConvert.DeserializeObject <AdminSettings>(pRequest.Body); AdminSettings vAdminModel = vDatabase.AdminSettings .FirstOrDefault(x => x.ClientId.Equals(vClientId) && x.SettingName.Equals(vInputModel.SettingName, StringComparison.InvariantCultureIgnoreCase)); if (vAdminModel == null) { vAdminModel = vInputModel; vAdminModel.ClientId = vClientId; vDatabase.Add(vAdminModel); } vAdminModel.SettingValue = vInputModel.SettingValue; vAdminModel.UpdatedBy = vInputModel.UpdatedBy; vAdminModel.UpdatedTimestamp = vInputModel.UpdatedTimestamp; vAdminModel.ClientId = vClientId; vDatabase.SaveChanges(); return(HttpHelper.HandleResponse(JsonConvert.SerializeObject(vAdminModel), 200)); } } } } catch (Exception vException) { vResponse = HttpHelper.HandleError("[AdminSettings] Error Connecting to DB: " + vException.Message, 500); } return(vResponse); }
private APIGatewayProxyResponse HandleRaidTickRequest(opendkpContext pDatabase, UserRequests pUserRequest, APIGatewayProxyRequest pRequest, CognitoUser pCognitoUser) { var vResponse = HttpHelper.HandleError("[UserRequestsLambda] Issue with DB or Query", 500); //We need to retrieve the ClientId for multitenancy purposes var vClientId = pRequest.Headers["clientid"]; if (!string.IsNullOrWhiteSpace(pUserRequest.RequestDetails)) { dynamic vModel = JsonConvert.DeserializeObject(pUserRequest.RequestDetails); //`{characterName:${this.CharacterName},tickId=${this.SelectedData.TickId},reason:${this.LogData}}`; string vCharacterName = vModel.characterName; int vTickId = vModel.tickId; string vReason = vModel.reason; //First, lets make sure the Character Exists in the Database! Characters vCharacter = CharacterHelper.GetCharacterByName(pDatabase, vClientId, vCharacterName); if (vCharacter == null) { return(HttpHelper.HandleError(string.Format("{0} does not exist in the database...", vCharacterName), 500)); } //Second, lets confirm the Character is associated with the Account var vUser = pDatabase.UserXCharacter.FirstOrDefault(x => x.ClientId.Equals(vClientId) && x.IdCharacter == vCharacter.IdCharacter && x.User.Equals(pCognitoUser.Username)); if (vUser == null) { return(HttpHelper.HandleError(string.Format("{0} is not associated with your account", vCharacterName), 500)); } //Determine if this character already has the raid tick var vFound = pDatabase.TicksXCharacters.FirstOrDefault(x => x.ClientId.Equals(vClientId) && x.IdCharacter == vCharacter.IdCharacter && x.IdTick == vTickId); if (vFound != null) { return(HttpHelper.HandleError("You already have credit for this raid tick!", 500)); } //Verify that there is not already an open pending request var vPendingRequests = pDatabase.UserRequests.Where(x => x.ClientId.Equals(vClientId) && x.RequestType == UserRequests.TYPE_RAIDTICK && x.RequestStatus == UserRequests.STATUS_PENDING).ToList(); foreach (var vRequest in vPendingRequests) { dynamic vTmpModel = JsonConvert.DeserializeObject(vRequest.RequestDetails); string vTmpName = vTmpModel.characterName; int vTmpId = vTmpModel.tickId; if (vTmpId == vTickId && vCharacterName.Trim().Equals(vTmpName.Trim(), StringComparison.InvariantCultureIgnoreCase)) { return(HttpHelper.HandleError("There is already a pending request for this character & raid tick!", 500)); } } pUserRequest.Requestor = pCognitoUser.Username; pUserRequest.RequestStatus = UserRequests.STATUS_PENDING; pUserRequest.RequestTimestamp = DateTime.Now; pUserRequest.RequestApprover = "NONE"; pUserRequest.ReviewedTimestamp = DateTime.Now; pUserRequest.ClientId = vClientId; pDatabase.Add(pUserRequest); pDatabase.SaveChanges(); vResponse = HttpHelper.HandleResponse(pUserRequest, 200, true); } return(vResponse); }
private APIGatewayProxyResponse UpdateRaidTickRequest(opendkpContext pDatabase, UserRequests pUserRequest, CognitoUser pCognitoUser, string pClientId) { var vResponse = HttpHelper.HandleError("[UserRequestsLambda] Issue with DB or Query", 500); if (!string.IsNullOrWhiteSpace(pUserRequest.Requestor) && !string.IsNullOrWhiteSpace(pUserRequest.RequestDetails)) { if (pUserRequest.RequestStatus == UserRequests.STATUS_APPROVED) { dynamic vModel = JsonConvert.DeserializeObject(pUserRequest.RequestDetails); //`{characterName:${this.CharacterName},tickId=${this.SelectedData.TickId},reason:${this.LogData}}`; string vCharacterName = vModel.characterName; int vTickId = vModel.tickId; string vReason = vModel.reason; //I need to associate the character //If character associate is successful, I need to update pending request to completed using (var dbContextTransaction = pDatabase.Database.BeginTransaction()) { //First, lets make sure the Character Exists in the Database! Characters vCharacter = CharacterHelper.GetCharacterByName(pDatabase, pClientId, vCharacterName); if (vCharacter == null) { return(HttpHelper.HandleError(string.Format("{0} does not exist in the database...", vCharacterName), 500)); } //Determine if this character already has the raid tick var vFound = pDatabase.TicksXCharacters.FirstOrDefault(x => x.ClientId.Equals(pClientId) && x.IdCharacter == vCharacter.IdCharacter && x.IdTick == vTickId); if (vFound != null) { return(HttpHelper.HandleError("You already have credit for this raid tick!", 500)); } TicksXCharacters vTickToInsert = new TicksXCharacters(); vTickToInsert.IdCharacter = vCharacter.IdCharacter; vTickToInsert.IdTick = vTickId; vTickToInsert.ClientId = pClientId; pDatabase.Add(vTickToInsert); //Update the Request UserRequests vRequest = pDatabase.UserRequests.FirstOrDefault(x => x.ClientId.Equals(pClientId) && x.Id == pUserRequest.Id); if (vRequest == null) { return(HttpHelper.HandleError("[UserRequestsLambda] Couldn't find the Request in DB to update...", 500)); } vRequest.RequestApprover = pCognitoUser.Username; vRequest.ReviewedTimestamp = DateTime.Now; vRequest.RequestStatus = UserRequests.STATUS_APPROVED; vRequest.ClientId = pClientId; pDatabase.SaveChanges(); dbContextTransaction.Commit(); //Update Caches int vStatus = CacheManager.UpdateSummaryCacheAsync(pClientId).GetAwaiter().GetResult(); Console.WriteLine("SummaryCacheResponse=" + vStatus); vResponse = HttpHelper.HandleResponse(vRequest, 200, true); } } else if (pUserRequest.RequestStatus == UserRequests.STATUS_DENIED) { UserRequests vRequest = pDatabase.UserRequests.FirstOrDefault(x => x.ClientId.Equals(pClientId) && x.Id == pUserRequest.Id); if (vRequest == null) { return(HttpHelper.HandleError("[UserRequestsLambda] Couldn't find the Request in DB to update...", 500)); } vRequest.RequestApprover = pCognitoUser.Username; vRequest.ReviewedTimestamp = DateTime.Now; vRequest.RequestStatus = UserRequests.STATUS_DENIED; vRequest.RequestDetails = pUserRequest.RequestDetails; vRequest.ClientId = pClientId; pDatabase.SaveChanges(); vResponse = HttpHelper.HandleResponse(vRequest, 200, true); } } return(vResponse); }