示例#1
0
        public async Task <IActionResult> DeleteConfirmed(int movieId, int customerId, DateTime?loanDate)
        {
            Loan loan = await _context.Loan.FindAsync(movieId, customerId, loanDate);

            await _context.Entry(loan).Reference(l => l.Movie).LoadAsync();

            await _context.Entry(loan).Reference(l => l.Customer).LoadAsync();

            _context.Loan.Remove(loan);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "MembershipTypeId,Name,SignUpFee,DurationInMonths,DiscountRate")] MembershipType membershipType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(membershipType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(membershipType));
 }
 public ActionResult Edit([Bind(Include = "Id,Nome,IsSubscribedToNewsletter,MembershipTypeId")] Cliente cliente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cliente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MembershipTypeId = new SelectList(db.MembershipTypes, "MembershipTypeId", "MembershipTypeId", cliente.MembershipTypeId);
     return(View(cliente));
 }
示例#4
0
        public async Task <IActionResult> Edit([Bind("MovieId,Name,ReleaseDate,Producer,GenreId,Price")] Movie movieToEdit)
        {
            if (ModelState.IsValid)
            {
                if (_context.Movie.AsNoTracking().SingleOrDefault(x => x.MovieId == movieToEdit.MovieId) != null)
                {
                    _context.Entry(movieToEdit).State = EntityState.Modified;
                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.GenreId = new SelectList(_context.Genre, "GenreId", "Name", movieToEdit.GenreId);
            return(View(movieToEdit));
        }