Ejemplo n.º 1
0
        public JsonResult List(int page, int rows, string CID, int?Status, string BeginTime = "", string EndTime = "")
        {
            RecommendInfoQuery model = new RecommendInfoQuery();

            model.Plat_Code = CID;
            model.Status    = Status;
            DateTime dt;

            if (DateTime.TryParse(BeginTime, out dt) && DateTime.TryParse(EndTime, out dt))
            {
                model.BeginTime = DateTime.Parse(BeginTime);
                model.EndTime   = DateTime.Parse(EndTime);
                model.PageNo    = page;
                model.PageSize  = rows;
            }
            else
            {
                model.PageNo   = page;
                model.PageSize = rows;
            }
            PageModel <RecommendInfo> opModel = ServiceHelper.Create <IRecommendInfoService>().GetRecommendInfos(model);
            var array =
                from item in opModel.Models.ToArray()
                select new { Id = item.Id, CID = item.CID, CASNO = item.CASNO, ProductName = item.ProductName, Structure_2D = item.Structure_2D, Price = item.Price, Status = item.Status, Plat_Code = item.Plat_Code };

            return(Json(new { rows = array, total = opModel.Total }));
        }
Ejemplo n.º 2
0
        public PageModel <RecommendInfo> GetRecommendInfos(RecommendInfoQuery model)
        {
            int pageNum = 0;
            IQueryable <RecommendInfo> recommendInfo = from item in base.context.RecommendInfo
                                                       select item;
            string begin = model.BeginTime.ToString("yyyy/MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string end   = model.EndTime.ToString("yyyy/MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);

            if (!string.IsNullOrWhiteSpace(begin) && !begin.Equals("0001/01/01") && !string.IsNullOrWhiteSpace(end) && !end.Equals("0001/01/01"))
            {
                recommendInfo = (from a in recommendInfo where a.ActiveTime >= model.BeginTime && a.ActiveTime <= model.EndTime select a);
            }
            if (model.Status.HasValue && model.Status.Value != 0)
            {
                recommendInfo = (from a in recommendInfo where a.Status == model.Status.Value select a);
            }
            //平台货号查询
            if (!string.IsNullOrWhiteSpace(model.Plat_Code))
            {
                recommendInfo = (from a in recommendInfo where a.Plat_Code == model.Plat_Code select a);
            }
            recommendInfo = recommendInfo.GetPage(out pageNum, model.PageNo, model.PageSize, (IQueryable <RecommendInfo> d) =>
                                                  from o in d
                                                  orderby o.ActiveTime descending
                                                  select o);

            return(new PageModel <RecommendInfo>
            {
                Models = recommendInfo,
                Total = pageNum
            });
        }