public async Task <IActionResult> Create([Bind("FirstName,LastName,User_CPF,URLProfilePicture,Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] ApplicationUser applicationUser)
        {
            if (ModelState.IsValid)
            {
                //applicationUser.URLProfilePicture = "/images/users/sem foto.jpg";
                _context.Add(applicationUser);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(applicationUser));
        }
        public async Task <IActionResult> Create(string Comment, [Bind("NewspaperCommentID,UserID,NewspaperID,Comment,CommentDate,CommentEnabled")] NewspaperComment newspaperComment)
        {
            var userId = int.Parse(_userManager.GetUserId(HttpContext.User));

            newspaperComment.UserID         = userId;
            newspaperComment.CommentDate    = DateTime.Now;
            newspaperComment.CommentEnabled = true;
            newspaperComment.Comment        = Comment;
            _context.Add(newspaperComment);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Details", "Newspapers", new { id = newspaperComment.NewspaperID }));
        }
        public async Task <IActionResult> Create(string Comment, [Bind("MultimediaCommentID,UserID,MultimediaID,Comment,CommentDate,CommentEnabled")] MultimediaComment multimediaComment)
        {
            var userId = int.Parse(_userManager.GetUserId(HttpContext.User));

            multimediaComment.UserID         = userId;
            multimediaComment.CommentDate    = DateTime.Now;
            multimediaComment.CommentEnabled = true;
            multimediaComment.Comment        = Comment;
            _context.Add(multimediaComment);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Details", "Multimedias", new { id = multimediaComment.MultimediaID }));
        }
Example #4
0
        public async Task <IActionResult> Create(int id, [Bind("BookLoanID,LoanDate,DevolutionDate,DevolutionDateMade,UserID,BookID")] BookLoan bookLoan)
        {
            if (ModelState.IsValid)
            {
                bookLoan.BookID             = id;
                bookLoan.LoanDate           = DateTime.Now;
                bookLoan.DevolutionDateMade = DateTime.Now.AddDays(7);
                _context.Add(bookLoan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookID"] = new SelectList(_context.Book, "BookID", "Edition", bookLoan.BookID);
            return(View(bookLoan));
        }
Example #5
0
        public async Task <IActionResult> Create(int id, [Bind("MultimediaLoanID,LoanDate,DevolutionDate,DevolutionDateMade,UserID,MultimediaID")] MultimediaLoan multimediaLoan)
        {
            if (ModelState.IsValid)
            {
                multimediaLoan.MultimediaID       = id;
                multimediaLoan.LoanDate           = DateTime.Now;
                multimediaLoan.DevolutionDateMade = DateTime.Now.AddDays(7);
                _context.Add(multimediaLoan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"]       = new SelectList(_context.ApplicationUsers, "Id", "FirstName", multimediaLoan.UserID);
            ViewData["MultimediaID"] = new SelectList(_context.Multimedia, "MultimediaID", "DGM", multimediaLoan.MultimediaID);
            return(View(multimediaLoan));
        }
        public async Task <IActionResult> Create(int id, [Bind("NewspaperLoanID,LoanDate,DevolutionDate,DevolutionDateMade,UserID,NewspaperID")] NewspaperLoan newspaperLoan)
        {
            if (ModelState.IsValid)
            {
                newspaperLoan.NewspaperID        = id;
                newspaperLoan.LoanDate           = DateTime.Now;
                newspaperLoan.DevolutionDateMade = DateTime.Now.AddDays(7);
                _context.Add(newspaperLoan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"]      = new SelectList(_context.ApplicationUsers, "Id", "FirstName", newspaperLoan.UserID);
            ViewData["NewspaperID"] = new SelectList(_context.Newspapers, "NewspaperID", "CurrentPeriodicity", newspaperLoan.NewspaperID);
            return(View(newspaperLoan));
        }
        public async Task <IActionResult> Create(List <IFormFile> AvatarImage, [Bind("MultimediaID,TitleMain,DGM,SubTitle,Director,PlaceOfPublication,PublishingCompany,YearOfPublication,PhysicalDescription,MultimediaSubject,Abstract,NoteOfParticipants,TargetAudience,Language,URLImage")] Multimedia multimedia)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in AvatarImage)
                {
                    if (item.Length > 0)
                    {
                        using (var stream = new MemoryStream())
                        {
                            await item.CopyToAsync(stream);

                            multimedia.AvatarImage = stream.ToArray();
                        }
                    }
                }
                _context.Add(multimedia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(multimedia));
        }
        public async Task <IActionResult> Create(List <IFormFile> AvatarImage, [Bind("NewspaperID,TitleMain,SubTitle,Edition,PlaceOfPublication,PublishingCompany,NewspaperSubject,CurrentPeriodicity, ISSN, URLImage")] Newspaper newspaper)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in AvatarImage)
                {
                    if (item.Length > 0)
                    {
                        using (var stream = new MemoryStream())
                        {
                            await item.CopyToAsync(stream);

                            newspaper.AvatarImage = stream.ToArray();
                        }
                    }
                }
                _context.Add(newspaper);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(newspaper));
        }
Example #9
0
        public async Task <IActionResult> Create(List <IFormFile> AvatarImage, [Bind("BookID,TitleMain,SubTitle,AuthorMain,Authors,Edition,PlaceOfPublication,PublishingCompany,YearOfPublication,TotalPages,BookSubject, Abstract, ISBN, URLImage,URLEbook")] Book book)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in AvatarImage)
                {
                    if (item.Length > 0)
                    {
                        using (var stream = new MemoryStream())
                        {
                            await item.CopyToAsync(stream);

                            book.AvatarImage = stream.ToArray();
                        }
                    }
                }
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }