public ActionResult Edit(Ingrediente ingrediente)
 {
     if (ModelState.IsValid)
     {
         db.Ingredientes.Attach(ingrediente);
         db.ObjectStateManager.ChangeObjectState(ingrediente, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.IdUsuario = new SelectList(db.Usuarios, "Id", "Email", ingrediente.IdUsuario);
     return View(ingrediente);
 }
        public ActionResult Create(Ingrediente ingrediente)
        {
            ingrediente.IdUsuario = 7;
            //Añadimos la fecha de creación.
            ingrediente.FechaCreacion = DateTime.Now;

            if (ModelState.IsValid)
            {
                db.Ingredientes.AddObject(ingrediente);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.IdUsuario = new SelectList(db.Usuarios, "Id", "Email", ingrediente.IdUsuario);
            return View(ingrediente);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Ingredientes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIngredientes(Ingrediente ingrediente)
 {
     base.AddObject("Ingredientes", ingrediente);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a new Ingrediente object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="idUsuario">Initial value of the IdUsuario property.</param>
 /// <param name="nombre">Initial value of the Nombre property.</param>
 /// <param name="descripcion">Initial value of the Descripcion property.</param>
 /// <param name="fechaCreacion">Initial value of the FechaCreacion property.</param>
 public static Ingrediente CreateIngrediente(global::System.Int32 id, global::System.Int32 idUsuario, global::System.String nombre, global::System.String descripcion, global::System.DateTime fechaCreacion)
 {
     Ingrediente ingrediente = new Ingrediente();
     ingrediente.Id = id;
     ingrediente.IdUsuario = idUsuario;
     ingrediente.Nombre = nombre;
     ingrediente.Descripcion = descripcion;
     ingrediente.FechaCreacion = fechaCreacion;
     return ingrediente;
 }