public ActionResult Create(Specialty specialty)
        {
            if (!_db.Specialties.Any(x => x.Name == specialty.Name))
            {
                _db.Specialties.Add(specialty);
                _db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Create(Doctor doctor, Specialty specialty)
        {
            _db.Doctors.Add(doctor);


            // _db.DoctorSpecialty.Add(new DoctorSpecialty() { DoctorId = doctor.DoctorId, SpecialtyId = specialty.SpecialtyId });

            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Create(Specialty specialty, int DoctorId) //create new doctor for specialty
 {
     _db.Specialty.Add(specialty);
     if (DoctorId != 0)
     {
         _db.DoctorSpecialty.Add(new DoctorSpecialty()
         {
             DoctorId = DoctorId, SpecialtyId = specialty.SpecialtyId
         });
     }
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 4
0
 public ActionResult Create(Patient patient, int DoctorId)
 {
     _db.Patients.Add(patient);
     if (DoctorId != 0)
     {
         _db.DoctorPatient.Add(new DoctorPatient()
         {
             DoctorId = DoctorId, PatientId = patient.PatientId
         });
     }
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 5
0
 public ActionResult Create(Doctor doctor, int SpecialtyId) //Create the new doctor from the form submit
 {
     if (SpecialtyId != 0)
     {
         _db.DoctorSpecialty.Add(new DoctorSpecialty()
         {
             DoctorId = doctor.DoctorId, SpecialtyId = SpecialtyId
         });
     }
     _db.Doctors.Add(doctor);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 6
0
        public ActionResult Edit(Patient patient, int DoctorId)
        {
            var testVariable = _db.DoctorPatient.FirstOrDefault(join => join.PatientId == patient.PatientId && join.DoctorId == DoctorId);

            if (testVariable != null)
            {
                _db.Entry(patient).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Details", new { id = patient.PatientId }));
            }
            if (DoctorId != 0)
            {
                _db.DoctorPatient.Add(new DoctorPatient()
                {
                    DoctorId = DoctorId, PatientId = patient.PatientId
                });
            }
            _db.Entry(patient).State = EntityState.Modified;
            _db.SaveChanges();
            return(RedirectToAction("Details", new { id = patient.PatientId }));
        }
 public ActionResult Create(Specialty specialty)
 {
     _db.Specialties.Add(specialty);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Create(Doctor doctor)
 {
     _db.Doctors.Add(doctor);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }