Exemple #1
0
        public async Task <IActionResult> AddLibro(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var autor = await _dataContext.Autors.FindAsync(id);

            if (autor == null)
            {
                return(NotFound());
            }

            var model = new LibroViewModel
            {
                AutorId    = autor.Id,
                Editorials = _combosHelper.GetComboEditorials()
            };

            return(View(model));
        }
 public LibroViewModel ToLibroViewModel(Libro libro)
 {
     return(new LibroViewModel
     {
         Titulo = libro.Titulo,
         Sinopsis = libro.Sinopsis,
         Paginas = libro.Paginas,
         Id = libro.Id,
         Autor = libro.Autor,
         ImagenLibros = libro.ImagenLibros,
         Editorial = libro.Editorial,
         AutorId = libro.Autor.Id,
         EditorialId = libro.Editorial.Id,
         Editorials = _combosHelper.GetComboEditorials()
     });
 }