Example #1
0
 public void DeleteComplexObject(PlanDefinition plan)
 {
     try
     {
         for (int i = plan.PhaseDefinition.Count - 1; i >= 0; i--)
         {
             var phase = plan.PhaseDefinition.ToList()[i];
             for (int j = phase.TaskDefinition.Count - 1; j >= 0; j--)
             {
                 var task = phase.TaskDefinition.ToList()[j];
                 for (int k = task.MedicalOrderDefinition.Count - 1; k >= 0; k--)
                 {
                     this.MedicalOrderDefinition.Remove(task.MedicalOrderDefinition.ToList()[k]);
                 }
                 this.TaskDefinition.Remove(task);
             }
             this.PhaseDefinition.Remove(phase);
         }
         this.PlanDefinition.Remove(plan);
     }
     catch (DbEntityValidationException dbEx)
     {
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
             }
         }
     }
     catch (DbUpdateException dbEx)
     {
         Trace.TraceInformation("DbUpdateException" + dbEx.Message);
     }
     catch (Exception ex)
     {
         Trace.TraceInformation(ex.Message);
     }
 }
Example #2
0
 public void AddComplexObject(PlanDefinition plan)
 {
     try
     {
         foreach (var phase in plan.PhaseDefinition)
         {
             foreach (var task in phase.TaskDefinition)
             {
                 foreach (var medicalOrder in task.MedicalOrderDefinition)
                 {
                     this.MedicalOrderDefinition.Add(medicalOrder);
                 }
                 this.TaskDefinition.Add(task);
             }
             this.PhaseDefinition.Add(phase);
         }
         this.PlanDefinition.Add(plan);
     }
     catch (DbEntityValidationException dbEx)
     {
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
             }
         }
     }
     catch (DbUpdateException dbEx)
     {
         Trace.TraceInformation("DbUpdateException" + dbEx.Message);
     }
     catch (Exception ex)
     {
         Trace.TraceInformation(ex.Message);
     }
 }