Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,LastName,FirstName,Telephone,Direction")] ClienteDTO clienteDTO)
        {
            var client = mapper.Map <Client>(clienteDTO);

            if (id != client.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clienteDTO));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("PrestamoID,FechaPrestamo,FechaDevolucion,ClientID,PeliculaID")] PrestamoDTO prestamoDTO)
        {
            var prestamo = mapper.Map <Prestamo>(prestamoDTO);

            if (id != prestamo.PrestamoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prestamo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrestamoExists(prestamo.PrestamoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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(prestamoDTO));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("PeliculaID,NombrePelicula,Año,Duracion")] PeliculaDTO peliculaDTO)
        {
            var pelicula = mapper.Map <Pelicula>(peliculaDTO);

            if (id != pelicula.PeliculaID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pelicula);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PeliculaExists(pelicula.PeliculaID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }


            return(View(peliculaDTO));
        }