private void btnEkle_Click(object sender, EventArgs e) { User hasta = new User(); hasta.FirstName = txtAd.Text; hasta.LastName = txtSoyad.Text; hasta.NationalIdentity = txtTc.Text; hasta.Email = txtMail.Text; hasta.PhoneNumber = txtTel.Text; var result1 = userManager.Add(hasta); hasta = userManager.GetAll().SingleOrDefault(p => p.NationalIdentity == txtTc.Text); Patient hastaDetay = new Patient(); hastaDetay.Id = hasta.Id; hastaDetay.illnessid = illnesManager.GetAll().SingleOrDefault(p => p.illnessName == cmbHastalık.Text).illnessid; hastaDetay.DietId = dietManager.GetAll().SingleOrDefault(p => p.DietName == cmbDiyet.Text).DietId; hastaDetay.PatientDescription = rchSikayet.Text; var result2 = patientManager.Add(hastaDetay); if (result1 && result2) { MessageBox.Show("Hasta eklendi !"); this.Hide(); } else { MessageBox.Show("Hasta eklenemedi !"); } }
public ActionResult Add(PatientViewModel vm) { try { _manager.Add(vm.Patient); return(RedirectToAction("Index", new { id = vm.Patient.Id, status = "success" })); } catch (Exception e) { return(RedirectToAction("Index", new { id = vm.Patient.Id, status = "fail" })); } }
/// <summary> /// /// </summary> /// <param name="parameter"></param> public void Execute(object parameter) { PatientManager patientManager = new PatientManager(); PatientDetailModel patientDetail = parameter as PatientDetailModel; if (patientManager.Add(new PatientDetailModel { Id = patientDetail.Id, Name = patientDetail.Name })) { MessageBox.Show("Patient Add Successful !"); } else { MessageBox.Show("Patient with this ID already exists !"); } }
/// <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 !"); } }