public ViewResult Index() { var viewModel = new RoadConditionIndexViewModel { StartDate = DateTime.Today.ToString(), EndDate = DateTime.Today.AddDays(-1).ToString(), Summary = new RoadConditionSummaryViewModel { PercentChainsRequiredAllVehicles = 0, PercentChainsRequiredExceptAllWheelDrive = 0, PercentPassClosed = 0, PercentTractionTiresAdvised = 0, PercentTractionTiresRequired = 0, PercentTrafficDelayed = 0, PercentTrafficDelayedForAvalancheControl = 0, PercentTrafficStoppedForAvalancheControl = 0, } }; return View(viewModel); }
public ViewResult Index(string startDate, string endDate, string direction) { var start = DateTime.Parse(startDate); var end = DateTime.Parse(endDate); Direction? trafficDirection = null; if (direction != "All") trafficDirection = (Direction)Enum.Parse(typeof(Direction), direction); var dataInRange = _roadConditionRepository.Get() .Where(d => d.Start >= start) .Where(d => d.End <= end) .SelectMany(d => d.TravelRestrictions); if(trafficDirection.HasValue) dataInRange = dataInRange.Where(d => d.Direction == trafficDirection); var summary = MapSummary(dataInRange); var viewModel = new RoadConditionIndexViewModel { StartDate = startDate, EndDate = endDate, Direction = direction, Summary = summary }; return View(viewModel); }