Guest User

Untitled

a guest
Jan 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public class ReservationsController : Controller
  2. {
  3. private AppDbContext db = new AppDbContext();
  4.  
  5. // GET: Reservations
  6. public ActionResult Index()
  7. {
  8. return View(db.Reservations.ToList());
  9. }
  10.  
  11. // GET: Reservations/Create
  12. public ActionResult Create()
  13. {
  14. ViewBag.ScreeningId = new SelectList(db.Screenings, "Id", "Description");
  15.  
  16. HashSet<int> seats = new HashSet<int>(db.Reservations.Select(x => x.SeatNumber));
  17. ViewBag.Seats = seats;
  18. return View();
  19. }
  20.  
  21. <div class="form-group">
  22. @Html.LabelFor(model => model.Screening, "Seans", htmlAttributes: new { @class = "control-label col-md-2" })
  23. <div class="col-md-10">
  24. @Html.DropDownList("ScreeningId", null, htmlAttributes: new { @class = "form-control" })
  25. @Html.ValidationMessageFor(model => model.Screening, "", new { @class = "text-danger" })
  26. </div>
  27. </div>
  28.  
  29. 'There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'ScreeningId'.'
Add Comment
Please, Sign In to add comment