public IEnumerable <tblSchedule> GenerateSchedule(ScheduleParamsModel parameters) { var dateFrom = DateHelper.StringToDate(parameters.DateFrom); var dateTo = DateHelper.StringToDate(parameters.DateTo); var schedule = new List <tblSchedule>(); var fakeId = 0; if (!dateFrom.HasValue || !dateTo.HasValue || string.IsNullOrEmpty(parameters.LinesIds)) { return(null); } using (var logic = new LineLogic()) { var lines = logic.GetLinesByPlan(parameters.LinesIds.Split(',').Select(int.Parse)); foreach (var line in lines) { var dates = GetScheduleLineDates(line, dateFrom.Value, dateTo.Value, parameters); foreach (var date in dates) { var item = GenerateSingleSchedule(line, date, parameters.LeaveTime, parameters.ArriveTime); item.Id = fakeId++; schedule.Add(item); } } } return(schedule); }