public async Task <IActionResult> Edit(Guid id, [Bind("IdGenero,Nombre")] Genero genero)
        {
            if (id != genero.IdGenero)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genero);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GeneroExists(genero.IdGenero))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(genero));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("IdAlumno,Nombre,Matricula,Password,Activo,IdIdentity,Email")] Alumno alumno)
        {
            if (id != alumno.IdAlumno)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(alumno);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlumnoExists(alumno.IdAlumno))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(alumno));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("IdLibro,IdAutor")] AutorLibro autorLibro)
        {
            if (id != autorLibro.IdLibro)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(autorLibro);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AutorLibroExists(autorLibro.IdLibro))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdAutor"] = new SelectList(_context.Autores, "IdAutor", "IdAutor", autorLibro.IdAutor);
            ViewData["IdLibro"] = new SelectList(_context.Libros, "IdLibro", "IdLibro", autorLibro.IdLibro);
            return(View(autorLibro));
        }
示例#4
0
        public async Task <IActionResult> Edit(Guid id, [Bind("IdPrestamo,IdLibro,IdAlumno,Codigo,FechaPrestamo,FechaLimite,FechaDevolucion,IdStatusPrestamo,MontoMulta")] Prestamo prestamo)
        {
            if (id != prestamo.IdPrestamo)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prestamo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrestamoExists(prestamo.IdPrestamo))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdAlumno"]         = new SelectList(_context.Alumnos, "IdAlumno", "Nombre", prestamo.IdAlumno);
            ViewData["IdLibro"]          = new SelectList(_context.Libros, "IdLibro", "Titulo", prestamo.IdLibro);
            ViewData["IdStatusPrestamo"] = new SelectList(_context.StatusPrestamos, "IdStatusPrestamo", "Nombre", prestamo.IdStatusPrestamo);
            return(View(prestamo));
        }
示例#5
0
        public async Task <IActionResult> Edit(Guid id, [Bind("IdEditorial,Nombre")] Editorial editorial)
        {
            if (id != editorial.IdEditorial)
            {
                return(RedirectToAction(
                           nameof(Index),
                           new
                {
                    ac = "El registro no existe",
                    type = "danger"
                }));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(editorial);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EditorialExists(editorial.IdEditorial))
                    {
                        return(RedirectToAction(
                                   nameof(Index),
                                   new
                        {
                            ac = "El registro no existe",
                            type = "danger"
                        }));
                    }
                    else
                    {
                        return(RedirectToAction(
                                   nameof(Index),
                                   new
                        {
                            ac = "Error de concurrencia",
                            type = "danger"
                        }));
                    }
                }
                return(RedirectToAction(
                           nameof(Index),
                           new
                {
                    ac = "Regitro editado con exito",
                    type = "success"
                }));
            }
            return(View(editorial));
        }
示例#6
0
        public async Task <IActionResult> Edit(Guid id, [Bind("IdLibro,ISBN,Titulo,IdEditorial,IdGenero,IdPais,Año,Imagen")] Libro libro, IFormFile portada)
        {
            if (id != libro.IdLibro)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    libro.Imagen = await GuardarArchivo(portada, libro.Imagen);

                    _context.Update(libro);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LibroExists(libro.IdLibro))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdEditorial"] = new SelectList(_context.Editoriales, "IdEditorial", "Nombre", libro.IdEditorial);
            ViewData["IdGenero"]    = new SelectList(_context.Generos, "IdGenero", "Nombre", libro.IdGenero);
            ViewData["IdPais"]      = new SelectList(_context.Paises, "IdPais", "Nombre", libro.IdPais);
            ViewData["Autores"]     = new SelectList(_context.Autores, "IdAutor", "Nommbre");

            libro.Portada = DescargarImagen(libro.Imagen);

            return(View(libro));
        }