public static IEnumerable <TourWithGroups> ListTourWithGroups(DateTime?StartDate = null, DateTime?EndDate = null) { try { if (StartDate.HasValue && EndDate.HasValue) { new DateRange(StartDate.Value, EndDate.Value); } var listTours = TourDAL.Get(); var listTourWithGroups = listTours.Select(t => new TourWithGroups { Tour = t }).ToList(); //Check filter date in this listGroups; var listGroups = GroupDAL.Get( filter: g => (!StartDate.HasValue || !EndDate.HasValue) || (StartDate.Value <= g.StartDate && g.StartDate <= EndDate.Value), includeProperties: new List <Expression <Func <Group, object> > > { g => g.Tour, g => g.Costs, g => g.CustomerGroups, } ).ToList(); foreach (var group in listGroups) { int foundIndex = listTourWithGroups.FindIndex(ele => ele.Tour.Id == group.Tour.Id); if (foundIndex != -1) { listTourWithGroups[foundIndex].Groups.Add(group); } } return(listTourWithGroups); } catch (Exception ex) { throw ex; } }
public static IList <Group> ListGroups(string type = null, string value = null) { return(GroupDAL.Get(type, value)); }