public void UpdateBloodPressure(int patientNoteId, BloodPressure bloodPressure)
 {
     using (var dataContext = new eHealthCareEntities())
     {
         try
         {
             var bloodPressureToUpdate = GetBloodPressureById(bloodPressure.PatientId, patientNoteId);
             if (bloodPressureToUpdate != null)
             {
                 bloodPressureToUpdate.Systolic = bloodPressure.Systolic;
                 bloodPressureToUpdate.Diastolic = bloodPressure.Diastolic;
                 bloodPressureToUpdate.IrregularHeartbeat = bloodPressure.IrregularHeartbeat;
                 bloodPressureToUpdate.Pulse = bloodPressure.Pulse;
                 bloodPressureToUpdate.When = bloodPressure.When;
                 dataContext.BloodPressures.Attach(bloodPressureToUpdate);
                 dataContext.Entry(bloodPressureToUpdate).State = EntityState.Modified;
                 dataContext.SaveChanges();
             }
         }
         catch (DbEntityValidationException ex)
         {
             throw new Exception(ex.EntityValidationErrors.GetValidationErrors());
         }
         catch
         {
             throw;
         }
     }
 }
        private void SaveBloodPressure(object sender, RoutedEventArgs e)
        {
            try
            {
                var bloodPressureDataRepository = new BloodPressureDataRepository(EHealthCareDesktopApp.Properties.Settings.Default.UniqueIdentifier);
                var bloodPressure = new BloodPressure
                {
                    PatientId = EHealthCareDesktopApp.Properties.Settings.Default.PatientID,
                    When = dtPicker.SelectedDate.Value,
                    Systolic = int.Parse(txtSystolic.Text.Trim()),
                    Diastolic = int.Parse(txtDiastolic.Text.Trim()),
                    Pulse = int.Parse(txtPulse.Text.Trim()),
                };

                if (chkIrregularHeartBeat.IsChecked != null && (bool)chkIrregularHeartBeat.IsChecked)
                    bloodPressure.IrregularHeartbeat = true;
                else
                    bloodPressure.IrregularHeartbeat = false;

               bloodPressureDataRepository.SaveBloodPressure(bloodPressure);

               if (BloodPressureAddedEvent != null)
                   BloodPressureAddedEvent("Success");
            }
            catch(Exception ex)
            {
                if (BloodPressureAddedEvent != null)
                    BloodPressureAddedEvent(string.Format("Problem in adding BloodPressure Readings: {0}", ex.ToString()));
            }
        }
 public void SaveBloodPressure(BloodPressure bloodPressure)
 {
     using (var dataContext = new eHealthCareEntities())
     {
         try
         {
             bloodPressure.UniqueIdentifier = this.uniqueGuid;
             dataContext.BloodPressures.Add(bloodPressure);
             dataContext.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             throw new Exception(ex.EntityValidationErrors.GetValidationErrors());
         }
         catch
         {
             throw;
         }
     }
 }