コード例 #1
0
        public ActionResult Create(Telefono telefonoToCreate)
        {
            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(telefonoToCreate);
                }

                _db.AddToTelefonoSet(telefonoToCreate);

                _db.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #2
0
 /// <summary>
 /// Método desusado para agregar un nuevo objeto al EntitySet TelefonoSet. Considere la posibilidad de usar el método .Add de la propiedad ObjectSet&lt;T&gt; asociada.
 /// </summary>
 public void AddToTelefonoSet(Telefono telefono)
 {
     base.AddObject("TelefonoSet", telefono);
 }
コード例 #3
0
 /// <summary>
 /// Crear un nuevo objeto Telefono.
 /// </summary>
 /// <param name="iD_TELEFONO">Valor inicial de la propiedad ID_TELEFONO.</param>
 /// <param name="iD_PERSONA">Valor inicial de la propiedad ID_PERSONA.</param>
 public static Telefono CreateTelefono(global::System.Int32 iD_TELEFONO, global::System.Int32 iD_PERSONA)
 {
     Telefono telefono = new Telefono();
     telefono.ID_TELEFONO = iD_TELEFONO;
     telefono.ID_PERSONA = iD_PERSONA;
     return telefono;
 }
コード例 #4
0
        public ActionResult Edit(int id, Telefono telefonoToEdit)
        {
            try
            {
                // TODO: Add update logic here
                var originalTel = (from m in _db.TelefonoSet

                                    where m.ID_TELEFONO == telefonoToEdit.ID_TELEFONO

                                    select m).First();

                if (!ModelState.IsValid)

                    return View(originalTel);

                _db.ApplyCurrentValues(originalTel.EntityKey.EntitySetName, telefonoToEdit);

                _db.SaveChanges();

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