Esempio n. 1
0
 /// <summary>
 /// Add Patient
 /// </summary>
 /// <param name="patient">Patient to add</param>
 /// <returns></returns>
 public bool Add(Patient patient)
 {
     //Search if the patient exists and if not add the patient.
     if (patientRepository.Search(patient.Id) == null)
     {
         patientRepository.Add(patient);
         return true;
     }
     return false;
 }
 /// <summary>
 /// Instatiates all the readonly variables
 /// </summary>
 public PatientDetailViewModel()
 {
     domObject = new Patient();
     patientManager = new PatientManager();
     
     _patients = new ObservableCollection<Patient>();
     _addPatientCmd = new RelayCommand(Add, CanAdd);
     _deletePatientCmd = new RelayCommand(Delete, CanDelete);
     _searchPatientCmd = new RelayCommand(Search, CanSearch);
     _updatePatientCmd = new RelayCommand(Update, CanUpdate);
 }
 /// <summary>
 /// Add operation of the AddPatientCmd.
 /// Operation that will be performormed on the control click.
 /// </summary>
 /// <param name="obj"></param>
 public void Add(object obj)
 {
     //Always create a new instance of patient before adding. 
     //Otherwise we will endup sending the same instance that is binded, to the BL which will cause complications
     var patient = new Patient { Id = Id, Name = Name, MobileNumber=MobileNumber };
     //Add patient will be successfull only if the patient with same ID does not exist.
     if (patientManager.Add(patient))
     {
         Patients.Add(patient);
         ResetPatient();
         MessageBox.Show("Patient Add Successful !");
     }
     else
         MessageBox.Show("Patient with this ID already exists !");
 }