コード例 #1
0
        public async Task <IActionResult> Create([Bind("Name,Surname,Email,Password,Id")] Member member)
        {
            if (ModelState.IsValid)
            {
                member.Id = Guid.NewGuid();
                _context.Add(member);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(member));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Title,Author,Edition,Year,Quantity,Id")] Book book)
        {
            if (ModelState.IsValid)
            {
                book.Id = Guid.NewGuid();
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("IsReturned,RequestedOn,ReturnedOn,MemberId,BookId,Id")] Lend lend)
        {
            if (ModelState.IsValid)
            {
                lend.Id = Guid.NewGuid();
                _context.Add(lend);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]   = new SelectList(_context.Books, "Id", "Id", lend.BookId);
            ViewData["MemberId"] = new SelectList(_context.Members, "Id", "Id", lend.MemberId);
            return(View(lend));
        }