public RemoveProgramInPatientGoalsDataResponse RemoveProgramInPatientGoals(RemoveProgramInPatientGoalsDataRequest request) { RemoveProgramInPatientGoalsDataResponse response = null; try { response = new RemoveProgramInPatientGoalsDataResponse(); IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientGoal); if (request.ProgramId != null) { List <PatientGoalData> goals = repo.FindGoalsWithAProgramId(request.ProgramId) as List <PatientGoalData>; if (goals != null && goals.Count > 0) { goals.ForEach(u => { request.PatientGoalId = u.Id; if (u.ProgramIds != null && u.ProgramIds.Remove(request.ProgramId)) { repo.RemoveProgram(request, u.ProgramIds); } }); } } return(response); } catch (Exception ex) { throw ex; } }
public void RemoveProgram(object entity, List <string> updatedProgramIds) { RemoveProgramInPatientGoalsDataRequest request = (RemoveProgramInPatientGoalsDataRequest)entity; try { List <ObjectId> ids = updatedProgramIds.ConvertAll(r => ObjectId.Parse(r)); using (PatientGoalMongoContext ctx = new PatientGoalMongoContext(_dbName)) { var q = MB.Query <MEPatientGoal> .EQ(b => b.Id, ObjectId.Parse(request.PatientGoalId)); var uv = new List <MB.UpdateBuilder>(); uv.Add(MB.Update.SetWrapped <List <ObjectId> >(MEPatientGoal.ProgramProperty, ids)); uv.Add(MB.Update.Set(MEPatientGoal.LastUpdatedOnProperty, DateTime.UtcNow)); uv.Add(MB.Update.Set(MEPatientGoal.UpdatedByProperty, ObjectId.Parse(this.UserId))); IMongoUpdate update = MB.Update.Combine(uv); ctx.PatientGoals.Collection.Update(q, update); AuditHelper.LogDataAudit(this.UserId, MongoCollectionName.PatientGoal.ToString(), request.PatientGoalId.ToString(), Common.DataAuditType.Update, request.ContractNumber); } } catch (Exception) { throw; } }
public RemoveProgramInPatientGoalsDataResponse Put(RemoveProgramInPatientGoalsDataRequest request) { RemoveProgramInPatientGoalsDataResponse response = new RemoveProgramInPatientGoalsDataResponse(); try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("PatientGoalDD:RemoveProgramInPatientGoals()::Unauthorized Access"); } response = Manager.RemoveProgramInPatientGoals(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); }