/// <summary> /// 获取数据 /// </summary> /// <param name="query">查询条件</param> /// <returns></returns> protected override async Task <TriggerCondition> GetDataAsync(IQuery query) { List <TriggerWeeklyConditionEntity> weekEntityList = await repositoryWarehouse.GetListAsync(query); if (weekEntityList.IsNullOrEmpty()) { return(null); } string triggerId = weekEntityList.First().TriggerId; TriggerWeeklyCondition weekCondtion = new TriggerWeeklyCondition(triggerId) { Days = weekEntityList.Where(c => c.TriggerId == triggerId).Select(c => c.MapTo <WeeklyConditionDay>()).ToList() }; return(weekCondtion); }
/// <summary> /// 获取数据列表 /// </summary> /// <param name="query">查询条件</param> /// <returns></returns> protected override async Task <List <TriggerCondition> > GetDataListAsync(IQuery query) { List <TriggerWeeklyConditionEntity> weekEntityList = await repositoryWarehouse.GetListAsync(query); if (weekEntityList.IsNullOrEmpty()) { return(new List <TriggerCondition>(0)); } IEnumerable <string> triggerIds = weekEntityList.Select(c => c.TriggerId).Distinct(); List <TriggerCondition> weekConditions = new List <TriggerCondition>(); foreach (string triggerId in triggerIds) { TriggerWeeklyCondition weekCondtion = new TriggerWeeklyCondition(triggerId) { Days = weekEntityList.Where(c => c.TriggerId == triggerId).Select(c => c.MapTo <WeeklyConditionDay>()).ToList() }; weekConditions.Add(weekCondtion); } return(weekConditions); }