public ActionResult Create([Bind(Include = "id,date,startTime,endTime,locationId,showId,guest")] Slot slot) { if (ModelState.IsValid) { sr.AddSlot(slot); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.locationId = new SelectList(db.Locations, "id", "name", slot.locationId); ViewBag.showId = new SelectList(db.Shows, "id", "title", slot.showId); return(View(slot)); }
// Add a new slot public void AddSlot(SlotViewModel slot) { var newSlot = new Slot { PresentationId = slot.PresentationId, SpeakerId = slot.SpeakerId, RoomId = slot.RoomId, StartTime = slot.StartTime, EndTime = slot.EndTime }; _slotRepo.AddSlot(newSlot); _slotRepo.SaveChanges(); }