public async Task <IActionResult> Create([Bind("PrestamoID,FechaPrestamo,FechaDevolucion,ClientID,PeliculaID")] Prestamo prestamo) { if (ModelState.IsValid) { _context.Add(prestamo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClientID"] = new SelectList(_context.Clientes, "ID", "ID", prestamo.ClientID); ViewData["PeliculaID"] = new SelectList(_context.Peliculas, "PeliculaID", "PeliculaID", prestamo.PeliculaID); return(View(prestamo)); }
public async Task <IActionResult> Create([Bind("ID,LastName,FirstName,Telephone,Direction")] ClienteDTO clienteDTO) { var client = mapper.Map <Client>(clienteDTO); if (ModelState.IsValid) { _context.Add(client); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(clienteDTO)); }
public async Task <IActionResult> Create([Bind("PeliculaID,NombrePelicula,Año,Duracion")] PeliculaDTO peliculaDTO) { var pelicula = mapper.Map <Pelicula>(peliculaDTO); if (ModelState.IsValid) { _context.Add(pelicula); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(peliculaDTO)); }