public void UndoDelete(object entity)
        {
            UndoDeleteInterventionDataRequest request = (UndoDeleteInterventionDataRequest)entity;

            try
            {
                using (PatientGoalMongoContext ctx = new PatientGoalMongoContext(_dbName))
                {
                    var q = MB.Query <MEPatientIntervention> .EQ(b => b.Id, ObjectId.Parse(request.InterventionId));

                    var uv = new List <MB.UpdateBuilder>();
                    uv.Add(MB.Update.Set(MEPatientIntervention.TTLDateProperty, BsonNull.Value));
                    uv.Add(MB.Update.Set(MEPatientIntervention.DeleteFlagProperty, false));
                    uv.Add(MB.Update.Set(MEPatientIntervention.UpdatedByProperty, ObjectId.Parse(this.UserId)));
                    uv.Add(MB.Update.Set(MEPatientIntervention.LastUpdatedOnProperty, DateTime.UtcNow));

                    IMongoUpdate update = MB.Update.Combine(uv);
                    ctx.PatientInterventions.Collection.Update(q, update);

                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.PatientIntervention.ToString(),
                                             request.InterventionId.ToString(),
                                             Common.DataAuditType.UndoDelete,
                                             request.ContractNumber);
                }
            }
            catch (Exception) { throw; }
        }
Exemple #2
0
        public UndoDeletePatientGoalDataResponse UndoDeletePatientGoals(UndoDeletePatientGoalDataRequest request)
        {
            UndoDeletePatientGoalDataResponse response = null;

            try
            {
                response = new UndoDeletePatientGoalDataResponse();
                IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientGoal);
                if (request.Ids != null && request.Ids.Count > 0)
                {
                    request.Ids.ForEach(u =>
                    {
                        request.PatientGoalId = u.Id;
                        repo.UndoDelete(request);

                        #region Delete Barriers
                        if (u.PatientBarrierIds != null && u.PatientBarrierIds.Count > 0)
                        {
                            IGoalRepository barrierRepo = Factory.GetRepository(request, RepositoryType.PatientBarrier);
                            u.PatientBarrierIds.ForEach(b =>
                            {
                                UndoDeleteBarrierDataRequest barrierRequest = new UndoDeleteBarrierDataRequest
                                {
                                    BarrierId      = b,
                                    Context        = request.Context,
                                    ContractNumber = request.ContractNumber,
                                    UserId         = request.UserId,
                                    Version        = request.Version
                                };
                                barrierRepo.UndoDelete(barrierRequest);
                            });
                        }

                        #endregion

                        #region Delete Tasks
                        if (u.PatientTaskIds != null && u.PatientTaskIds.Count > 0)
                        {
                            IGoalRepository taskRepo = Factory.GetRepository(request, RepositoryType.PatientTask);
                            u.PatientTaskIds.ForEach(t =>
                            {
                                UndoDeleteTaskDataRequest taskRequest = new UndoDeleteTaskDataRequest
                                {
                                    TaskId         = t,
                                    Context        = request.Context,
                                    ContractNumber = request.ContractNumber,
                                    UserId         = request.UserId,
                                    Version        = request.Version
                                };
                                taskRepo.UndoDelete(taskRequest);
                            });
                        }
                        #endregion

                        #region Delete Interventions
                        if (u.PatientInterventionIds != null && u.PatientInterventionIds.Count > 0)
                        {
                            IGoalRepository interventionRepo = Factory.GetRepository(request, RepositoryType.PatientIntervention);
                            u.PatientInterventionIds.ForEach(i =>
                            {
                                UndoDeleteInterventionDataRequest interventionRequest = new UndoDeleteInterventionDataRequest
                                {
                                    InterventionId = i,
                                    Context        = request.Context,
                                    ContractNumber = request.ContractNumber,
                                    UserId         = request.UserId,
                                    Version        = request.Version
                                };
                                interventionRepo.UndoDelete(interventionRequest);
                            });
                        }
                        #endregion
                    });
                }
                response.Success = true;
                return(response);
            }
            catch (Exception ex) { throw ex; }
        }