コード例 #1
0
 public IActionResult Create([Bind("Id,MovieName,Genre,Price")] Movie movie)
 {
     if (ModelState.IsValid)
     {
         _context.Add(movie);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(movie));
 }
コード例 #2
0
 public IActionResult Create([Bind("Id,CustomerName,Email")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         _context.Add(customer);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(customer));
 }
コード例 #3
0
 public IActionResult Create([Bind("Id,CustomerId,CommentText")] Comment comment)
 {
     if (ModelState.IsValid)
     {
         _context.Add(comment);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "Id", "CustomerName", comment.CustomerId);
     return(View(comment));
 }
コード例 #4
0
 public IActionResult Create([Bind("Id,MovieId,CustomerId")] MovieTransaction movieTransaction)
 {
     if (ModelState.IsValid)
     {
         _context.Add(movieTransaction);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "CustomerName", movieTransaction.CustomerId);
     ViewData["MovieId"]    = new SelectList(_context.Movie, "Id", "MovieName", movieTransaction.MovieId);
     return(View(movieTransaction));
 }