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

            try
            {
                using (ProgramMongoContext ctx = new ProgramMongoContext(_dbName))
                {
                    var query = MB.Query <MEPatientProgram> .EQ(b => b.Id, ObjectId.Parse(request.PatientProgramId));

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

                    IMongoUpdate update = MB.Update.Combine(builder);
                    ctx.PatientPrograms.Collection.Update(query, update);

                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.PatientProgram.ToString(),
                                             request.PatientProgramId.ToString(),
                                             Common.DataAuditType.UndoDelete,
                                             request.ContractNumber);
                }
            }
            catch (Exception) { throw; }
        }
Esempio n. 2
0
        public UndoDeletePatientProgramDataResponse Put(UndoDeletePatientProgramDataRequest request)
        {
            UndoDeletePatientProgramDataResponse response = new UndoDeletePatientProgramDataResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("ProgramDD:PatientProgramUndoDelete()::Unauthorized Access");
                }

                response         = ProgramDataManager.UndoDeletePatientPrograms(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);
        }
Esempio n. 3
0
 public UndoDeletePatientProgramDataResponse UndoDeletePatientPrograms(UndoDeletePatientProgramDataRequest request)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
        public UndoDeletePatientProgramDataResponse UndoDeletePatientPrograms(UndoDeletePatientProgramDataRequest request)
        {
            UndoDeletePatientProgramDataResponse response = null;

            try
            {
                response = new UndoDeletePatientProgramDataResponse();
                IProgramRepository ppRepo           = Factory.GetRepository(request, RepositoryType.PatientProgram);
                IProgramRepository ppAttributesRepo = Factory.GetRepository(request, RepositoryType.PatientProgramAttribute);
                IProgramRepository ppResponsesRepo  = Factory.GetRepository(request, RepositoryType.PatientProgramResponse);
                if (request.Ids != null && request.Ids.Count > 0)
                {
                    List <DeletedPatientProgram> PatientProgramIds = request.Ids;
                    PatientProgramIds.ForEach(u =>
                    {
                        #region PatientProgram
                        if (u.Id != null)
                        {
                            request.PatientProgramId = u.Id;
                            ppRepo.UndoDelete(request);
                        }
                        #endregion

                        #region PPAttributes
                        if (u.PatientProgramAttributeId != null)
                        {
                            UndoDeletePatientProgramAttributesDataRequest attrRequest = new UndoDeletePatientProgramAttributesDataRequest
                            {
                                Context                   = request.Context,
                                ContractNumber            = request.ContractNumber,
                                PatientProgramAttributeId = u.PatientProgramAttributeId,
                                UserId  = request.UserId,
                                Version = request.Version
                            };
                            ppAttributesRepo.UndoDelete(attrRequest);
                        }
                        #endregion

                        #region PPResponses
                        List <string> responseIds = u.PatientProgramResponsesIds;
                        if (responseIds != null && responseIds.Count > 0)
                        {
                            responseIds.ForEach(r =>
                            {
                                UndoDeletePatientProgramResponsesDataRequest respRequest = new UndoDeletePatientProgramResponsesDataRequest
                                {
                                    Context                  = request.Context,
                                    ContractNumber           = request.ContractNumber,
                                    PatientProgramResponseId = r,
                                    UserId  = request.UserId,
                                    Version = request.Version
                                };
                                ppResponsesRepo.UndoDelete(respRequest);
                            });
                        }
                        #endregion
                    });
                }
                response.Success = true;
                return(response);
            }
            catch (Exception ex) { throw ex; }
        }