public ActionResult Management(LunchAdministrationTaskEnum task = LunchAdministrationTaskEnum.EnterLunchDecision) { using (var dbContext = new DatabaseContext()) { var polls = LunchAPI.GetPolls(dbContext, DateTime.Now); return View("Management", new LunchAdministrationViewModel(polls, task)); } }
public LunchAdministrationViewModel(IEnumerable<LunchPoll> polls, LunchAdministrationTaskEnum task) : this() { AdministrationTasks.Single(sli => sli.Value == task.ToString()).Selected = true; LunchPolls = polls.Select(p => new SelectListItem { Text = p.Name, Value = p.Id.ToString() }).ToList(); }