public ActionResult Create(Laboratorista laboratoristaToCreate) { 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(laboratoristaToCreate); } _db.AddToLaboratoristaSet(laboratoristaToCreate); _db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
/// <summary> /// Método desusado para agregar un nuevo objeto al EntitySet LaboratoristaSet. Considere la posibilidad de usar el método .Add de la propiedad ObjectSet<T> asociada. /// </summary> public void AddToLaboratoristaSet(Laboratorista laboratorista) { base.AddObject("LaboratoristaSet", laboratorista); }
/// <summary> /// Crear un nuevo objeto Laboratorista. /// </summary> /// <param name="iD_PERSONA">Valor inicial de la propiedad ID_PERSONA.</param> /// <param name="jVPM_LAB">Valor inicial de la propiedad JVPM_LAB.</param> public static Laboratorista CreateLaboratorista(global::System.Int32 iD_PERSONA, global::System.Int32 jVPM_LAB) { Laboratorista laboratorista = new Laboratorista(); laboratorista.ID_PERSONA = iD_PERSONA; laboratorista.JVPM_LAB = jVPM_LAB; return laboratorista; }
public ActionResult Edit(int id, Laboratorista laboratoristaToEdit) { try { // TODO: Add update logic here var originalLab = (from m in _db.LaboratoristaSet where m.JVPM_LAB == laboratoristaToEdit.JVPM_LAB select m).First(); if (!ModelState.IsValid) return View(originalLab); _db.ApplyCurrentValues(originalLab.EntityKey.EntitySetName, laboratoristaToEdit); _db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }