public PostSaveActionResponse SaveActionResults(PostSaveActionRequest request) { try { // need to refactor this into a mediator. RelatedChanges.Clear(); PostSaveActionResponse response = new PostSaveActionResponse(); Program p = EndPointUtils.RequestPatientProgramDetail(request); Actions action = request.Action; // set elementstates to in progress Module mod = PEUtils.FindElementById(p.Modules, action.ModuleId); // set to in progress if (mod.ElementState == (int)ElementState.NotStarted) //!= 4 { mod.ElementState = (int)ElementState.InProgress; //4; mod.StateUpdatedOn = DateTime.UtcNow; } if (PEUtils.IsActionInitial(p)) { // set program to in progress if (p.ElementState == (int)ElementState.NotStarted) { p.ElementState = (int)ElementState.InProgress; //4; p.StateUpdatedOn = System.DateTime.UtcNow; } } NGUtils.UpdateProgramAction(action, p); AddUniquePlanElementToProcessedList(mod); // save EndPointUtils.SaveAction(request, action.Id, p, false); //response.Program = p; response.Saved = true; response.RelatedChanges = RelatedChanges; response.PatientId = request.PatientId; response.Version = request.Version; return(response); } catch (Exception ex) { throw new Exception("AD:InterviewManager:ProcessActionResults()::" + ex.Message, ex.InnerException); } }
public PostSaveActionResponse Post(PostSaveActionRequest request) { var response = new PostSaveActionResponse(); var intm = new PlanManager(); ValidateTokenResponse result = null; try { request.Token = base.Request.Headers["Token"] as string; result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber); if (result.UserId.Trim() != string.Empty) { request.UserId = result.UserId; response = intm.SaveActionResults(request); } else { throw new UnauthorizedAccessException(); } } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); if ((ex is WebServiceException) == false) { intm.LogException(ex); } } finally { List <string> patientIds = null; if (!string.IsNullOrEmpty(response.PatientId)) { patientIds = new List <string> { response.PatientId }; } if (result != null) { AuditHelper.LogAuditData(request, result.SQLUserId, patientIds, System.Web.HttpContext.Current.Request, request.GetType().Name); } } return(response); }