public ActionResult Create(Doctor doctorToCreate)
        {
            try
            {
                // TODO: Add insert logic here
                if (!ModelState.IsValid)
                {
                    var query = _db.PersonaSet.Select(c => new
                    {
                        ID_PERSONA = c.ID_PERSONA,
                        PRIMER_NOMBRE = c.PRIMER_NOMBRE + " " + c.PRIMER_APELLIDO
                    });

                    ViewBag.ID_PERSONA = new SelectList(query.AsEnumerable(), "ID_PERSONA", "PRIMER_NOMBRE");

                    return View(doctorToCreate);
                }

                _db.AddToDoctorSet(doctorToCreate);

                _db.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Delete(int id, Doctor doctorToDelete)
        {
            try
            {
                // TODO: Add delete logic here
                var doctorDelete = (from m in _db.DoctorSet

                                     where m.JVPM_DOC == id

                                     select m).First();

                _db.DeleteObject(doctorDelete);

                _db.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 /// <summary>
 /// Método desusado para agregar un nuevo objeto al EntitySet DoctorSet. Considere la posibilidad de usar el método .Add de la propiedad ObjectSet&lt;T&gt; asociada.
 /// </summary>
 public void AddToDoctorSet(Doctor doctor)
 {
     base.AddObject("DoctorSet", doctor);
 }
 /// <summary>
 /// Crear un nuevo objeto Doctor.
 /// </summary>
 /// <param name="iD_PERSONA">Valor inicial de la propiedad ID_PERSONA.</param>
 /// <param name="jVPM_DOC">Valor inicial de la propiedad JVPM_DOC.</param>
 public static Doctor CreateDoctor(global::System.Int32 iD_PERSONA, global::System.Int32 jVPM_DOC)
 {
     Doctor doctor = new Doctor();
     doctor.ID_PERSONA = iD_PERSONA;
     doctor.JVPM_DOC = jVPM_DOC;
     return doctor;
 }
        public ActionResult Edit(int id, Doctor doctorToEdit)
        {
            try
            {
                // TODO: Add update logic here
                var originalDoct = (from m in _db.DoctorSet

                                      where m.JVPM_DOC == doctorToEdit.JVPM_DOC

                                      select m).First();

                if (!ModelState.IsValid)

                    return View(originalDoct);

                _db.ApplyCurrentValues(originalDoct.EntityKey.EntitySetName, doctorToEdit);

                _db.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }