public PutUpdateGoalDataResponse PutPatientGoal(PutUpdateGoalDataRequest request) { try { PutUpdateGoalDataResponse result = new PutUpdateGoalDataResponse(); IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientGoal); if (request.Goal != null) { bool status = (bool)repo.Update(request); if (status) { PatientGoalData data = repo.FindByID(request.Goal.Id) as PatientGoalData; result.GoalData = data; } } return(result); } catch (Exception ex) { throw ex; } }
public PutUpdateGoalDataResponse Put(PutUpdateGoalDataRequest request) { PutUpdateGoalDataResponse response = new PutUpdateGoalDataResponse(); try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("PatientGoalDD:Put()::Unauthorized Access"); } response = Manager.PutPatientGoal(request); response.Version = request.Version; } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } return(response); }
public object Update(object entity) { bool result = false; PutUpdateGoalDataRequest pgr = (PutUpdateGoalDataRequest)entity; PatientGoalData pt = pgr.Goal; try { using (PatientGoalMongoContext ctx = new PatientGoalMongoContext(_dbName)) { var q = MB.Query <MEPatientGoal> .EQ(b => b.Id, ObjectId.Parse(pt.Id)); var uv = new List <MB.UpdateBuilder>(); uv.Add(MB.Update.Set(MEPatientGoal.TTLDateProperty, BsonNull.Value)); uv.Add(MB.Update.Set(MEPatientGoal.DeleteFlagProperty, false)); uv.Add(MB.Update.Set(MEPatientGoal.VersionProperty, pgr.Version)); uv.Add(MB.Update.Set(MEPatientGoal.LastUpdatedOnProperty, DateTime.UtcNow)); uv.Add(MB.Update.Set(MEPatientGoal.UpdatedByProperty, ObjectId.Parse(this.UserId))); if (pt.PatientId != null) { uv.Add(MB.Update.Set(MEPatientGoal.PatientIdProperty, ObjectId.Parse(pt.PatientId))); } if (pt.FocusAreaIds != null) { uv.Add(MB.Update.SetWrapped <List <ObjectId> >(MEPatientGoal.FocusAreaProperty, DTOUtil.ConvertObjectId(pt.FocusAreaIds))); } if (pt.Name != null) { uv.Add(MB.Update.Set(MEPatientGoal.NameProperty, pt.Name)); } if (pt.SourceId != null) { uv.Add(MB.Update.Set(MEPatientGoal.SourceProperty, ObjectId.Parse(pt.SourceId))); } if (pt.ProgramIds != null) { uv.Add(MB.Update.SetWrapped <List <ObjectId> >(MEPatientGoal.ProgramProperty, DTOUtil.ConvertObjectId(pt.ProgramIds))); } if (pt.TypeId != null) { uv.Add(MB.Update.Set(MEPatientGoal.TypeProperty, pt.TypeId)); } if (pt.StatusId != 0) { uv.Add(MB.Update.Set(MEPatientGoal.StatusProperty, pt.StatusId)); } if (pt.TargetValue != null) { uv.Add(MB.Update.Set(MEPatientGoal.TargetValueProperty, pt.TargetValue)); } if (pt.StartDate != null) { uv.Add(MB.Update.Set(MEPatientGoal.StartDateProperty, pt.StartDate)); } else { uv.Add(MB.Update.Set(MEPatientGoal.StartDateProperty, BsonNull.Value)); } if (pt.EndDate != null) { uv.Add(MB.Update.Set(MEPatientGoal.EndDateProperty, pt.EndDate)); } else { uv.Add(MB.Update.Set(MEPatientGoal.EndDateProperty, BsonNull.Value)); } if (pt.TargetDate != null) { uv.Add(MB.Update.Set(MEPatientGoal.TargetDateProperty, pt.TargetDate)); } else { uv.Add(MB.Update.Set(MEPatientGoal.TargetDateProperty, BsonNull.Value)); } if (pt.CustomAttributes != null) { uv.Add(MB.Update.SetWrapped <List <MAttribute> >(MEPatientGoal.AttributesProperty, DTOUtil.GetAttributes(pt.CustomAttributes))); } IMongoUpdate update = MB.Update.Combine(uv); ctx.PatientGoals.Collection.Update(q, update); AuditHelper.LogDataAudit(this.UserId, MongoCollectionName.PatientGoal.ToString(), pt.Id.ToString(), Common.DataAuditType.Update, pgr.ContractNumber); result = true; } return(result as object); } catch (Exception) { throw; } }