コード例 #1
0
ファイル: LibroController.cs プロジェクト: juampinp/Bookflix
        public async Task <IActionResult> CreateConCapitulos([Bind("ISBN,Portada,Titulo,Descripcion,AutorId,GeneroId,EditorialId")] LibroViewModel l)
        {
            if (ModelState.IsValid && !isbnUnico(l.ISBN))
            {
                string stringFileNamePortada = this.UploadFile(l.Portada, "Images");
                var    libro = new Libro

                {
                    ISBN                = l.ISBN,
                    Portada             = stringFileNamePortada,
                    Titulo              = l.Titulo,
                    Contenido           = null,
                    Descripcion         = l.Descripcion,
                    AutorId             = l.AutorId,
                    EditorialId         = l.EditorialId,
                    GeneroId            = l.GeneroId,
                    EstadoCompleto      = false,
                    CantidadComentarios = 0
                };


                _context.Add(libro);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Capitulo", new { id = libro.Id }));
                // return RedirectToAction(nameof(Index));
            }
            ViewData["AutorId"]     = new SelectList(_context.Autores, "Id", "Nombre", l.AutorId);
            ViewData["EditorialId"] = new SelectList(_context.Editoriales, "Id", "Nombre", l.EditorialId);
            ViewData["GeneroId"]    = new SelectList(_context.Generos, "Id", "Nombre", l.GeneroId);
            return(View(l));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id, Contenido")] Notificacion notificacion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(notificacion);
                await _context.SaveChangesAsync();

                return(RedirectToAction("crear", new { id = notificacion.Id }));
            }
            return(View(notificacion));
        }
コード例 #3
0
ファイル: AutorController.cs プロジェクト: juampinp/Bookflix
 public async Task<IActionResult> Create([Bind("Id,Nombre,Apellido")] Autor autor)
 {
     if (ModelState.IsValid)
     {
         _context.Add(autor);
         await _context.SaveChangesAsync();
         return RedirectToAction("Create","Autor");
         // return RedirectToAction(nameof(Index));
     }
     return View(autor);
 }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("Nombre,Apellido,Dni,FechaDeNacimiento,Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] BookflixUser bookflixUser)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bookflixUser);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bookflixUser));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Id,Nombre,Pais")] Editorial editorial)
        {
            if (ModelState.IsValid)
            {
                _context.Add(editorial);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Editorial"));
                //return RedirectToAction(nameof(Index));
            }
            return(View(editorial));
        }
コード例 #6
0
ファイル: GeneroController.cs プロジェクト: juampinp/Bookflix
        public async Task <IActionResult> Create([Bind("Id,Nombre")] Genero genero)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genero);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Genero"));
                //return RedirectToAction(nameof(Index));
            }
            return(View(genero));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("LibroId,PerfilId,Puntaje,Comentario,Spoiler,Visible")] Perfil_Valora_Libro perfil_Valora_Libro)
        {
            if (ModelState.IsValid)
            {
                _context.Add(perfil_Valora_Libro);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LibroId"]  = new SelectList(_context.Libros, "Id", "Descripcion", perfil_Valora_Libro.LibroId);
            ViewData["PerfilId"] = new SelectList(_context.Perfiles, "Id", "Nombre", perfil_Valora_Libro.PerfilId);
            return(View(perfil_Valora_Libro));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Id,LibroId,PerfilId,Motivo")] Reportes reportes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(reportes);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Libro", new { id = reportes.LibroId }));
            }

            ViewBag.IdLibro  = reportes.LibroId;
            ViewBag.PerfilId = reportes.PerfilId;
            return(View(reportes));
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("Id,Nombre,Activo")] Perfil perfil)
        {
            if (perfilUnico(perfil))
            {
                ModelState.AddModelError("Nombre", "Este nombre ya está utilizado por otro perfil");
            }
            if (ModelState.IsValid)
            {
                perfil.Usuario = await _userManager.GetUserAsync(HttpContext.User);

                _context.Add(perfil);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(perfil));
        }
コード例 #10
0
        public async Task <IActionResult> Create([Bind("Id,Img,Descripcion,LibroId")] Trailer trailer)
        {
            if (ModelState.IsValid)
            {
                //trailer.Imagen = this.UploadFile(trailer.Img, "Images");
                var _trailer = new Trailer
                {
                    Descripcion = trailer.Descripcion,
                    Imagen      = this.UploadFile(trailer.Img, "Images"),
                    LibroId     = trailer.LibroId
                };
                _context.Add(_trailer);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Libro"));
            }
            //ViewData["LibroId"] = new SelectList(_context.Libros, "Id", "Descripcion", trailer.LibroId);
            return(View(trailer));
        }