Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ReservationsController : Controller
- {
- private AppDbContext db = new AppDbContext();
- // GET: Reservations
- public ActionResult Index()
- {
- return View(db.Reservations.ToList());
- }
- // GET: Reservations/Create
- public ActionResult Create()
- {
- ViewBag.ScreeningId = new SelectList(db.Screenings, "Id", "Description");
- HashSet<int> seats = new HashSet<int>(db.Reservations.Select(x => x.SeatNumber));
- ViewBag.Seats = seats;
- return View();
- }
- <div class="form-group">
- @Html.LabelFor(model => model.Screening, "Seans", htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.DropDownList("ScreeningId", null, htmlAttributes: new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.Screening, "", new { @class = "text-danger" })
- </div>
- </div>
- 'There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'ScreeningId'.'
Add Comment
Please, Sign In to add comment