public async Task <string> UpdateDetails(IncidentDetailsRequest detailsRequest) { Services.Log.Info("Incident Details Update Request [Hub]"); string responseText; var currentUserID = ((ServiceUser)Context.User).Id; stranddContext context = new stranddContext(); //Retrieve Incident Incident updateIncident = await(from r in context.Incidents where (r.Id == detailsRequest.IncidentGUID) select r).FirstOrDefaultAsync(); //Find the Incident to Edit and return Bad Response if not found if (updateIncident != null) { //Check for Submitted Status and Update if (detailsRequest.Notes != null) { updateIncident.StaffNotes = detailsRequest.Notes; } //Check for Submitted Pricing and Update if (detailsRequest.ConcertoCaseID != null) { updateIncident.ConcertoCaseID = detailsRequest.ConcertoCaseID; } } else { // Return Failed Response responseText = "Incident not found [" + detailsRequest.IncidentGUID + "] in the system"; Services.Log.Warn(responseText); return(responseText); } //Save record await context.SaveChangesAsync(); responseText = "Incident [" + updateIncident.Id + "] Details Updated"; Services.Log.Info(responseText); //Notifying Connected WebClients with IncidentInfo Package Clients.All.updateIncidentDetailsAdmin(new IncidentInfo(updateIncident)); Services.Log.Info("Connected Web Clients Updated"); await HistoryEvent.logHistoryEventAsync("INCIDENT_DETAILS_ADMIN", null, updateIncident.Id, currentUserID, null, null); //Return Successful Response return(responseText); }
public async Task <HttpResponseMessage> UpdateDetails(IncidentDetailsRequest detailsRequest) { Services.Log.Info("Incident Details Update Request [API]"); string responseText; stranddContext context = new stranddContext(); //Retrieve Incident Incident updateIncident = await(from r in context.Incidents where (r.Id == detailsRequest.IncidentGUID) select r).FirstOrDefaultAsync(); //Find the Incident to Edit and return Bad Response if not found if (updateIncident != null) { //Check for Submitted Status and Update if (detailsRequest.Notes != null) { updateIncident.StaffNotes = detailsRequest.Notes; } //Check for Submitted Pricing and Update if (detailsRequest.ConcertoCaseID != null) { updateIncident.ConcertoCaseID = detailsRequest.ConcertoCaseID; } } else { // Return Failed Response responseText = "Incident [" + detailsRequest.IncidentGUID + "] is not found in the system"; Services.Log.Warn(responseText); return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText)); } //Save record await context.SaveChangesAsync(); responseText = "Incident [" + updateIncident.Id + "] Details Updated"; Services.Log.Info(responseText); //Notifying Connect WebClients with IncidentInfo Package IHubContext hubContext = Services.GetRealtime <IncidentHub>(); hubContext.Clients.All.updateIncidentDetailsAdmin(new IncidentInfo(updateIncident)); Services.Log.Info("Connected Clients Updated"); //Return Successful Response return(this.Request.CreateResponse(HttpStatusCode.OK, responseText)); }