//public ActionResult Create([Bind(Include = "ID,IdCliente,IdRestaurante,IdPrato,DataReserva,HoraReserva,Quantidade")] Reserva reserva) public ActionResult Create([Bind(Include = "ID,IdCliente,IdRestaurante,IdPrato,DataReserva,HoraReserva,Quantidade")] Reserva reserva, int?PratoId) { if (ModelState.IsValid) { PratoDBContext dbPratos = new PratoDBContext(); Prato prato = dbPratos.Pratos.Find(PratoId); reserva.IdCliente = this.User.Identity.Name; reserva.NomeCliente = this.User.Identity.Name; reserva.IdPrato = prato.ID; reserva.NomePrato = prato.Nome; reserva.IdRestaurante = prato.RestauranteId; reserva.NomeRestaurante = restDb.Restaurantes.Find(prato.RestauranteId).Nome; db.Reservas.Add(reserva); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(reserva)); }
public RestaurantesController() { pratoDb = new PratoDBContext(); db = new RestauranteDBContext(); }