コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("LibraryID,PersonID,BooksID,BorrowedDate,DateBack,LengthBorrowed,Descriptions")] LibrarySystemRun librarySystemRun)
        {
            if (id != librarySystemRun.LibraryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(librarySystemRun);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LibrarySystemRunExists(librarySystemRun.LibraryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BooksID"]  = new SelectList(_context.Books, "BooksID", "Title", librarySystemRun.BooksID);
            ViewData["PersonID"] = new SelectList(_context.Persons, "PersonID", "PersonName", librarySystemRun.PersonID);
            return(View(librarySystemRun));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("LibraryID,PersonID,BooksID,BorrowedDate,DateBack,LengthBorrowed,Descriptions")] LibrarySystemRun librarySystemRun)
        {
            if (ModelState.IsValid)
            {
                _context.Add(librarySystemRun);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BooksID"]  = new SelectList(_context.Books, "BooksID", "Title", librarySystemRun.BooksID);
            ViewData["PersonID"] = new SelectList(_context.Persons, "PersonID", "PersonName", librarySystemRun.PersonID);
            return(View(librarySystemRun));
        }