Exemplo n.º 1
0
        public void UndoDelete(object entity)
        {
            UndoDeletePatientAllergiesDataRequest request = (UndoDeletePatientAllergiesDataRequest)entity;

            try
            {
                using (AllergyMongoContext ctx = new AllergyMongoContext(ContractDBName))
                {
                    var q = MB.Query <MEPatientAllergy> .EQ(b => b.Id, ObjectId.Parse(request.PatientAllergyId));

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

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

                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.PatientAllergy.ToString(),
                                             request.PatientAllergyId.ToString(),
                                             DataAuditType.UndoDelete,
                                             request.ContractNumber);
                }
            }
            catch (Exception) { throw; }
        }
Exemplo n.º 2
0
        public UndoDeletePatientAllergiesDataResponse UndoDeletePatientAllergies(UndoDeletePatientAllergiesDataRequest request)
        {
            UndoDeletePatientAllergiesDataResponse response = null;

            try
            {
                response = new UndoDeletePatientAllergiesDataResponse();

                var repo = AllergyRepositoryFactory.GetAllergyRepository(request, RepositoryType.PatientAllergy);
                if (request.Ids != null && request.Ids.Count > 0)
                {
                    request.Ids.ForEach(u =>
                    {
                        request.PatientAllergyId = u;
                        repo.UndoDelete(request);
                    });
                }
                response.Success = true;
                return(response);
            }
            catch (Exception ex) { throw ex; }
        }