Пример #1
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));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,UserId,ExpirationDate")] Library_Card library_Card)
        {
            if (ModelState.IsValid)
            {
                _context.Add(library_Card);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", library_Card.UserId);
            return(View(library_Card));
        }