public async Task <IActionResult> Edit(int id, [Bind("IdPedido,FechaPedido,HoraPedido,HoraEntrega,DireccionPedido,DetalleDireccion,Total,ActivoPedido,IdTarjeta,IdCliente,IdRestaurante,IdEstado")] TblPedido tblPedido) { if (id != tblPedido.IdPedido) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tblPedido); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TblPedidoExists(tblPedido.IdPedido)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdTarjeta"] = new SelectList(_context.TblTarjeta, "IdTarjeta", "NombreTarjeta", tblPedido.IdTarjeta); ViewData["IdEstado"] = new SelectList(_context.TblEstado, "IdEstado", "NombreEstado", tblPedido.IdEstado); ViewData["IdRestaurante"] = new SelectList(_context.TblRestaurante, "IdRestaurante", "DireccionRestaurante", tblPedido.IdRestaurante); return(View(tblPedido)); }
public async Task <IActionResult> Create([Bind("IdPedido,FechaPedido,HoraPedido,HoraEntrega,DireccionPedido,DetalleDireccion,Total,ActivoPedido,IdTarjeta,IdCliente,IdRestaurante,IdEstado")] TblPedido tblPedido) { if (ModelState.IsValid) { _context.Add(tblPedido); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdTarjeta"] = new SelectList(_context.TblTarjeta, "IdTarjeta", "NombreTarjeta", tblPedido.IdTarjeta); ViewData["IdEstado"] = new SelectList(_context.TblEstado, "IdEstado", "NombreEstado", tblPedido.IdEstado); ViewData["IdRestaurante"] = new SelectList(_context.TblRestaurante, "IdRestaurante", "DireccionRestaurante", tblPedido.IdRestaurante); return(View(tblPedido)); }