// GET: Events public ActionResult AddEvent(int workshopId) { var session = Session["Login"] as SessionModel; var viewModel = new AddEventModel(); if (session != null) { using (var db = new MechAppProjectEntities()) { var serviceEvents = db.ServiceEvents.Where(x => x.WorkshopService.WorkshopId == workshopId).ToList(); viewModel.CalendarEventsJson = serviceEvents.Select(x => new CalendarEventJson() { startDate = x.StartDate, endDate = x.EndDate, summary = x.WorkshopService.Title }).ToList(); var customerCars = db.Cars .Where(x => x.CustomerId == session.UserId) .Select(x => new SelectListItem() { Text = x.Model, Value = x.CarId.ToString() }) .ToList(); var workshopServices = db.WorkshopServices .Where(x => x.WorkshopId == workshopId) .Select(x => new SelectListItem() { Text = x.Title, Value = x.ServiceId.ToString() }) .ToList(); viewModel.CustomerCarsSelectList = new SelectList(customerCars, "Value", "Text"); viewModel.WorkshopServicesSelectList = new SelectList(workshopServices, "Value", "Text"); viewModel.ServiceHourSelectList = new SelectList(EventsHelper.GetHoursToSelect(6, 21, 15), "Value", "Text"); } } return(View(viewModel)); }