Esempio n. 1
0
        public FuncResult Select([FromBody] SearchDimStoreModel model)
        {
            model.page--; if (model.page < 0)
            {
                model.page = 0;
            }

            return(storeService.Select(model));
        }
        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public FuncResult Select(SearchDimStoreModel model)
        {
            IOrderedQueryable <DimStore> query = _context.DimStore.
                                                 Where(a =>
                                                       (
                                                           (string.IsNullOrWhiteSpace(model.StCode) || a.stCode.Contains(model.StCode)) &&
                                                           (string.IsNullOrWhiteSpace(model.StName) || a.stName.Contains(model.StName))
                                                       )
                                                       ).OrderByDescending(e => e.stCode);
            int total = query.Count();
            var data  = query.Skip(model.limit * model.page).Take(model.limit).ToList().Select(e => new
            {
                e.id,
                e.stCode,
                e.stRegion,
                e.stCity,
                e.stLocation,
                e.stBrand,
                e.stOM,
                e.stDM,
                e.stName,
                e.stName_en,
                e.stAddress,
                e.stAddress_en,
                e.stType,
                stOpenDate  = e.stOpenDate != null ? Convert.ToDateTime(e.stOpenDate).ToShortDateString() : "",
                stCloseDate = e.stCloseDate != null ? Convert.ToDateTime(e.stCloseDate).ToShortDateString() : "",
                e.stTel,
                e.stFax,
                e.stEmail,
                e.stIP,
                e.stSpace,
                e.stSeat,
                e.stBizTime,
                e.stPOST,
                e.stSM,
                e.stSMTel,
                e.stComments
            });

            return(new FuncResult()
            {
                IsSuccess = true, Content = new { data, total }
            });
        }