コード例 #1
0
        public void UndoDelete(object entity)
        {
            UndoDeleteTaskDataRequest request = (UndoDeleteTaskDataRequest)entity;

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

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

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

                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.PatientTask.ToString(),
                                             request.TaskId.ToString(),
                                             Common.DataAuditType.UndoDelete,
                                             request.ContractNumber);
                }
            }
            catch (Exception) { throw; }
        }
コード例 #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; }
        }