Example #1
0
        public async Task <IActionResult> PutBook(Guid id, Book book)
        {
            if (id != book.Id)
            {
                return(BadRequest());
            }

            _context.Entry(book).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
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));
        }
Example #3
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));
        }
Example #4
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));
        }