예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DateCreated,CustomerId,MovieId,Status,DateRented,DateReturned")] VideoKlub videoKlub)
        {
            if (id != videoKlub.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(videoKlub);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VideoKlubExists(videoKlub.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Name", videoKlub.CustomerId);
            ViewData["MovieId"]    = new SelectList(_context.Movies, "Id", "Name", videoKlub.MovieId);
            return(View(videoKlub));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,DateCreated,CustomerId,MovieId,Status,DateRented,DateReturned")] VideoKlub videoKlub)
        {
            if (ModelState.IsValid)
            {
                _context.Add(videoKlub);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Name", videoKlub.CustomerId);
            ViewData["MovieId"]    = new SelectList(_context.Movies, "Id", "Name", videoKlub.MovieId);
            return(View(videoKlub));
        }