Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("MultimediaLoanID,LoanDate,DevolutionDate,DevolutionDateMade,UserID,MultimediaID")] MultimediaLoan multimediaLoan)
        {
            if (id != multimediaLoan.MultimediaLoanID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(multimediaLoan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MultimediaLoanExists(multimediaLoan.MultimediaLoanID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"]       = new SelectList(_context.ApplicationUsers, "Id", "FirstName", multimediaLoan.UserID);
            ViewData["MultimediaID"] = new SelectList(_context.Multimedia, "MultimediaID", "TitleMain", multimediaLoan.MultimediaID);
            return(View(multimediaLoan));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("BookLoanID,LoanDate,DevolutionDate,DevolutionDateMade,UserID,BookID")] BookLoan bookLoan)
        {
            if (id != bookLoan.BookLoanID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bookLoan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookLoanExists(bookLoan.BookLoanID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookID"] = new SelectList(_context.Book, "BookID", "Edition", bookLoan.BookID);
            return(View(bookLoan));
        }
        public async Task <IActionResult> Edit(int id, [Bind("NewspaperLoanID,LoanDate,DevolutionDate,DevolutionDateMade,UserID,NewspaperID")] NewspaperLoan newspaperLoan)
        {
            if (id != newspaperLoan.NewspaperLoanID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(newspaperLoan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NewspaperLoanExists(newspaperLoan.NewspaperLoanID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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> DisabledComment(int id)
        {
            NewspaperComment newspaperComment = _context.NewspaperComments.Where(m => m.NewspaperCommentID == id).First();

            newspaperComment.CommentEnabled = false;
            _context.Update(newspaperComment);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Details", "Newspapers", new { id = newspaperComment.NewspaperID }));
        }
        public async Task <IActionResult> DisabledComment(int id)
        {
            BookComment bookComment = _context.BookComments.Where(bc => bc.BookCommentID == id).First();

            bookComment.CommentEnabled = false;
            _context.Update(bookComment);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Details", "Books", new { id = bookComment.BookID }));
        }
        public async Task <IActionResult> DisabledComment(int id)
        {
            MultimediaComment multimediaComment = _context.MultimediaComments.Where(m => m.MultimediaCommentID == id).First();

            multimediaComment.CommentEnabled = false;
            _context.Update(multimediaComment);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Details", "Multimedias", new { id = multimediaComment.MultimediaID }));
        }
        public async Task <IActionResult> Edit(int id, List <IFormFile> AvatarImage, [Bind("FirstName,LastName,User_CPF,URLProfilePicture, AvatarImage, Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] ApplicationUser applicationUser)
        {
            if (id != applicationUser.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var obj = _context.ApplicationUsers.FirstOrDefault(x => x.Id == id);
                    obj.FirstName         = applicationUser.FirstName;
                    obj.Email             = applicationUser.Email;
                    obj.LastName          = applicationUser.LastName;
                    obj.User_CPF          = applicationUser.User_CPF;
                    obj.URLProfilePicture = applicationUser.URLProfilePicture;

                    foreach (var item in AvatarImage)
                    {
                        if (item.Length > 0)
                        {
                            using (var stream = new MemoryStream())
                            {
                                await item.CopyToAsync(stream);

                                obj.AvatarImage = stream.ToArray();
                            }
                        }
                    }

                    _context.Update(obj);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    if (!ApplicationUserExists(applicationUser.Id))
                    {
                        return(Json(ex.Message));
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Details", "ApplicationUsers", new { id = id }));
            }

            return(View(applicationUser));
        }
        public async Task <IActionResult> Edit(int id, List <IFormFile> AvatarImage, [Bind("MultimediaID,TitleMain,DGM,SubTitle,Director,PlaceOfPublication,PublishingCompany,YearOfPublication,PhysicalDescription,MultimediaSubject,Abstract,NoteOfParticipants,TargetAudience,Language,URLImage")] Multimedia multimedia)
        {
            if (id != multimedia.MultimediaID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    foreach (var item in AvatarImage)
                    {
                        if (item.Length > 0)
                        {
                            using (var stream = new MemoryStream())
                            {
                                await item.CopyToAsync(stream);

                                multimedia.AvatarImage = stream.ToArray();
                            }
                        }
                    }
                    _context.Update(multimedia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MultimediaExists(multimedia.MultimediaID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(multimedia));
        }
        public async Task <IActionResult> Edit(int id, List <IFormFile> AvatarImage, [Bind("NewspaperID,TitleMain,SubTitle,Edition,PlaceOfPublication,PublishingCompany,NewspaperSubject,CurrentPeriodicity,ISSN,URLImage")] Newspaper newspaper)
        {
            if (id != newspaper.NewspaperID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    foreach (var item in AvatarImage)
                    {
                        if (item.Length > 0)
                        {
                            using (var stream = new MemoryStream())
                            {
                                await item.CopyToAsync(stream);

                                newspaper.AvatarImage = stream.ToArray();
                            }
                        }
                    }
                    _context.Update(newspaper);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NewspaperExists(newspaper.NewspaperID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(newspaper));
        }
Exemple #10
0
        public async Task <IActionResult> Edit(int id, List <IFormFile> AvatarImage, [Bind("BookID,TitleMain,SubTitle,AuthorMain,Authors,Edition,PlaceOfPublication,PublishingCompany,Year,TotalPages,BookSubject,Abstract,ISBN,URLImage,URLEbook")] Book book)
        {
            if (id != book.BookID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    foreach (var item in AvatarImage)
                    {
                        if (item.Length > 0)
                        {
                            using (var stream = new MemoryStream())
                            {
                                await item.CopyToAsync(stream);

                                book.AvatarImage = stream.ToArray();
                            }
                        }
                    }
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.BookID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }