Ejemplo n.º 1
0
 public void Save(Doctor doctor)   //We added public method that accepts one 'doctor' item (new or existing) which will be saved to the repository
 {
     if (doctor.Id == 0)
     {
         doctor.Id = _doctors.Count + 1;    //this assigns value to doctor ID from list _doctors
         _doctors.Add(doctor);         //this action adds new doctor to internal storage (this case is to list) 
     }
     else
     {
         //TODO this will allow you to edit exisiting doc info
     }
      
 }
        public ActionResult Save(AddDoctorForm form)
        {
            // Create new Doctor object
            Doctor doctor = new Doctor();

            // Populate Doctor’s Name from form.Name(new doc is empty but need to set values regardless)
            doctor.DoctorName = form.Name;

            // Save new Doctor object to repository  (call the Save method)
            Repository.Save(doctor);

            // After submission staying on the add page does not make sense, so instead lets show the listing of doctors (which should include the new one)

            
            return RedirectToAction("Index");    // this redirects to the listing page - Index
        }