/// <summary>
        /// 根据用餐时间获取单品食物
        /// </summary>
        /// <param name="time">用餐时间</param>
        /// <returns></returns>
        public Result <PageList <Dish> > SearchDishInfoByMealTime(MealTime time, PageSearchParam param)
        {
            Result <PageList <Dish> > result = new Result <PageList <Dish> >()
            {
                Data   = null,
                Status = true
            };

            param.SearchCode = time.GetHashCode().ToString();
            param.SearchType = 2;

            result.Data           = new PageList <Dish>();
            result.Data.PageIndex = param.PageIndex;
            result.Data.PageNumer = param.PageNumer;

            try
            {
                //查询符合条件的数据总条数
                result.Data.Count = DBConnectionManager.Instance.Reader.Count(new DishCountForSelectPageSpefication(param).Satifasy());
                //查询数据集合
                IList <DishInfo> dish = DBConnectionManager.Instance.Reader.Select <DishInfo>(new DishSelectPagesPefication(param).Satifasy());
                result.Data.List = dish.CopyList <DishInfo, Dish>();
            }
            catch (Exception ex)
            {
                result.Status     = false;
                result.Message    = "查询单品食物出错:" + ex.Message;
                result.StatusCode = "SD001";
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:SearchDishInfoByMealTime() .DishService"), LogType.ErrorLog);
            }

            return(result);
        }
Beispiel #2
0
        protected override CachedTask <FoodResponse> GetData(bool force, CancellationToken token)
        {
            if (!force)
            {
                return(CachedTask.NoNewData <FoodResponse>());
            }

            var request = new FoodRequest
            {
                Language = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName,
                MealTime = MealTime,
                Date     = MealDate,
                UserName = _credentials.UserName
            };

            Func <Task <FoodResponse> > getter = () => _menuService.GetMenusAsync(request, token);

            if (MealDate.Date == DateTime.Now.Date)
            {
                return(CachedTask.Create(getter, MealTime.GetHashCode(), DateTime.Now.Date.AddDays(1)));
            }
            return(CachedTask.DoNotCache(getter));
        }