Example #1
0
        public async Task <IActionResult> Edit(int id, int?Bookid, string?Bookname, [Bind("Id,Name,Description")] Tag tag)
        {
            if (id != tag.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tag);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TagExists(tag.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Tags", new { id = ViewBag.BookId, name = ViewBag.BookName }));
            }
            return(RedirectToAction("Index", "Tags", new { id = ViewBag.BookId, name = ViewBag.BookName }));
        }
Example #2
0
        public async Task <IActionResult> Edit(long id, [Bind("EmpId,Name,BirthDate,Gender,Address,Phone,Id")] Employee employee)
        {
            if (id != employee.EmpId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.EmpId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"] = new SelectList(_context.Positions, "Id", "Demands", employee.Id);
            return(View(employee));
        }
Example #3
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,FullName,Phone,NationalId,DateCheckedOut,ReturnDate,BookId")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Id", user.BookId);
            return(View(user));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,GenreId,BookId")] BookGenres bookGenres)
        {
            if (id != bookGenres.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bookGenres);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookGenresExists(bookGenres.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]  = new SelectList(_context.Books, "Id", "Name", bookGenres.BookId);
            ViewData["GenreId"] = new SelectList(_context.Genres, "Id", "Name", bookGenres.GenreId);
            return(View(bookGenres));
        }
Example #5
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Title,ISBN,PublishYear,Price,IsCheckedIn")] Book book)
        {
            if (id != book.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
Example #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Id,PagesNum,LanguageId,Description")] Books books)
        {
            if (id != books.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(books);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BooksExists(books.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LanguageId"] = new SelectList(_context.Language, "Id", "Lname", books.LanguageId);
            return(View(books));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Comment,UserId")] Requests requests)
        {
            if (id != requests.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(requests);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RequestsExists(requests.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", requests.UserId);
            return(View(requests));
        }
Example #8
0
        public async Task <IActionResult> Edit(int id, [Bind("BookRentId,RentDate,Qty,StudentId,BookId")] BookRent bookRent)
        {
            if (id != bookRent.BookRentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bookRent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookRentExists(bookRent.BookRentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]    = new SelectList(_context.Books, "BookId", "BookId", bookRent.BookId);
            ViewData["StudentId"] = new SelectList(_context.Students, "StudentId", "StudentId", bookRent.StudentId);
            return(View(bookRent));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Office,Year,BookId")] Published published)
        {
            if (id != published.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(published);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PublishedExists(published.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Name", published.BookId);
            return(View(published));
        }
        public async Task <IActionResult> Edit(int id, [Bind("BookId,BookName,BookPrice,BookAuthor")] ComuterScience comuterScience)
        {
            if (id != comuterScience.BookId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comuterScience);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ComuterScienceExists(comuterScience.BookId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(comuterScience));
        }
Example #11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FullName")] Readers readers)
        {
            if (id != readers.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(readers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReadersExists(readers.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(readers));
        }
Example #12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Branch branch)
        {
            if (id != branch.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(branch));
            }
            try
            {
                context.Update(branch);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!context.Branches.Exists(branch.Id))
                {
                    return(NotFound());
                }
                throw;
            }
        }
Example #13
0
        public async Task <IActionResult> Edit(int id, [Bind("StudentID,Email,Fines,FirstName,Grade,IssuedID,LastName,TeacherID")] Student student)
        {
            if (id != student.StudentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.StudentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["TeacherID"] = new SelectList(_context.Teachers, "TeacherID", "TeacherID", student.TeacherID);
            return(View(student));
        }
Example #14
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,BookId,AuthorId")] Wrote wrote)
        {
            if (id != wrote.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(wrote);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WroteExists(wrote.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            var book = await _context.Books.FindAsync(wrote.BookId);

            ViewData["AuthorId"] = new SelectList(_context.Authors, "Id", "Name", wrote.AuthorId);
            ViewData["BookId"]   = new SelectList(_context.Books, "Id", "Name", wrote.BookId);
            return(RedirectToAction("Index", "Wrotes", new { id = book.Id, name = book.Name }));
        }
        public async Task <IActionResult> Edit(int id,
                                               [Bind(
                                                    "Id,Classification,CopyNumber,CheckOutTimestamp,LastCheckedIn,DueDate,BranchId,HeldByPatronId,CheckoutPolicyId")]
                                               Holding holding)
        {
            if (id != holding.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(holding));
            }

            try
            {
                context.Update(holding);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!context.Holdings.Exists(holding.Id))
                {
                    return(NotFound());
                }
                throw;
            }
        }
Example #16
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,ReaderName,ReaderLastName,BirthdayDate,Adress,Phone,Passport,AddDate,ReadersPicsPath")] Reader reader)
        {
            if (id != reader.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reader);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReaderExists(reader.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reader));
        }
Example #17
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,ExpirationDate")] Library_Card library_Card)
        {
            if (id != library_Card.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(library_Card);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Library_CardExists(library_Card.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", library_Card.UserId);
            return(View(library_Card));
        }
        public async Task <IActionResult> Extend(uint BorrowId, int RemainingDays)
        {
            var borrow = await _context.Borrow.FindAsync(BorrowId);

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

            borrow.ExpectReturnDate = ((DateTime)borrow.ExpectReturnDate).AddMonths(RemainingDays);
            try
            {
                _context.Update(borrow);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BorrowExists(borrow.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Example #19
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TagId,BookId")] Description description)
        {
            if (id != description.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(description);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DescriptionExists(description.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Name", description.BookId);
            ViewData["TagId"]  = new SelectList(_context.Tags, "Id", "Name", description.TagId);
            return(View(description));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,BookID,ReaderID,BorrowDate")] Borrow borrow)
        {
            if (id != borrow.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(borrow);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BorrowExists(borrow.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookID"]   = new SelectList(_context.Books, "ID", "ID", borrow.BookID);
            ViewData["ReaderID"] = new SelectList(_context.Readers, "ID", "ID", borrow.ReaderID);
            return(View(borrow));
        }
Example #21
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Text,BookId,ReaderId")] Comment comment)
        {
            if (id != comment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentExists(comment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]   = new SelectList(_context.Books, "Id", "Name", comment.BookId);
            ViewData["ReaderId"] = new SelectList(_context.Readers, "Id", "Login", comment.ReaderId);
            return(View(comment));
        }
Example #22
0
        public async Task <IActionResult> Edit(int id, [Bind("GenreId,Name")] Genre genre)
        {
            if (id != genre.GenreId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genre);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenreExists(genre.GenreId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(genre));
        }
Example #23
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Lname")] Language language)
        {
            if (id != language.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(language);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LanguageExists(language.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(language));
        }
Example #24
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,PositionTitle,Salary,Duties,Demands")] Positions positions)
        {
            if (id != positions.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(positions);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PositionsExists(positions.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(positions));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Author author)
        {
            if (id != author.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(author);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AuthorExists(author.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(author));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Name,Id,Balance")] Patron patron)
        {
            if (id != patron.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    context.Update(patron);
                    await context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!context.Patrons.Exists(patron.Id))
                    {
                        return(NotFound());
                    }
                    throw;
                }
            }
            return(View(patron));
        }
Example #27
0
        public async Task <IActionResult> Edit(int id, [Bind("PatronID,LastName,FirstName,MembershipDate")] Patron patron)
        {
            if (id != patron.PatronID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(patron);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PatronExists(patron.PatronID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(patron));
        }
Example #28
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CardId,BookId")] History history)
        {
            if (id != history.CardId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(history);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HistoryExists(history.CardId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Id", history.BookId);
            ViewData["CardId"] = new SelectList(_context.Library_Card, "Id", "Id", history.CardId);
            return(View(history));
        }
Example #29
0
        public async Task <IActionResult> Edit(int id, [Bind("BookId,Title,ReleaseDate,Genre")] Book book)
        {
            if (id != book.BookId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.BookId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,HoldPlaced")] Hold hold)
        {
            if (id != hold.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hold);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HoldExists(hold.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hold));
        }