public ActionResult Create(Restaurante restaurante)
        {
            //Añadimos la ciudad y la fecha de creación.
            restaurante.FechaCreacion = DateTime.Now;
            restaurante.IdCiudad = 1;
            if (ModelState.IsValid)
            {
                db.Restaurantes.AddObject(restaurante);
                db.SaveChanges();

                //Añadimos el mensaje informando.
                Message msg = new Message()
                {
                    type = TypeMessage.Create,
                    text = String.Format(Resources.Mensajes.txtRestaurantAdded, restaurante.Nombre)
                };
                ViewBag.Message = msg;

                #region Añadimos las columnas.

                ColumnModel[] columns = GetColumnsForRestaurant();
                ViewBag.Column1 = columns[0];
                ViewBag.Column2 = columns[1];
                ViewBag.Column3 = columns[2];

                #endregion

                return View("Index");
            }

            ViewBag.IdCiudad = new SelectList(db.Ciudades, "Id", "Nombre", restaurante.IdCiudad);
            return View(restaurante);
        }
        public ActionResult Create(Restaurante restaurante)
        {
            if (ModelState.IsValid)
            {
                db.Restaurantes.AddObject(restaurante);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.IdCiudad = new SelectList(db.Ciudades, "Id", "Nombre", restaurante.IdCiudad);
            return View(restaurante);
        }
示例#3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Restaurantes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRestaurantes(Restaurante restaurante)
 {
     base.AddObject("Restaurantes", restaurante);
 }
示例#4
0
 /// <summary>
 /// Create a new Restaurante object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="idCiudad">Initial value of the IdCiudad property.</param>
 /// <param name="nombre">Initial value of the Nombre property.</param>
 /// <param name="direccion">Initial value of the Direccion property.</param>
 /// <param name="descripcion">Initial value of the Descripcion property.</param>
 /// <param name="fechaCreacion">Initial value of the FechaCreacion property.</param>
 public static Restaurante CreateRestaurante(global::System.Int32 id, global::System.Int32 idCiudad, global::System.String nombre, global::System.String direccion, global::System.String descripcion, global::System.DateTime fechaCreacion)
 {
     Restaurante restaurante = new Restaurante();
     restaurante.Id = id;
     restaurante.IdCiudad = idCiudad;
     restaurante.Nombre = nombre;
     restaurante.Direccion = direccion;
     restaurante.Descripcion = descripcion;
     restaurante.FechaCreacion = fechaCreacion;
     return restaurante;
 }
 public ActionResult Edit(Restaurante restaurante)
 {
     if (ModelState.IsValid)
     {
         db.Restaurantes.Attach(restaurante);
         db.ObjectStateManager.ChangeObjectState(restaurante, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.IdCiudad = new SelectList(db.Ciudades, "Id", "Nombre", restaurante.IdCiudad);
     return View(restaurante);
 }