コード例 #1
0
        public ActionResult List(GetProductListRequest request)
        {
            request.Type = UrlDecode(request.Type);

            if (!String.IsNullOrEmpty(request.Type))
            {
                if (request.Type.ToLower() == "refresh")
                {
                    return new RestfulResult
                    {
                        Data = _productDataService.RefreshProduct(new GetProductRefreshRequest
                            {
                                Page = request.Page,
                                Pagesize = request.Pagesize,
                                RefreshTs = request.RefreshTs,
                                Sort = request.Sort,
                                BrandId = request.BrandId,
                                Lat = request.Lat,
                                Lng = request.Lng,
                                TagId = request.TagId,
                                TopicId = request.TopicId,
                                PromotionId = request.PromotionId
                            })
                    };
                }
            }
            else
            {
                return new RestfulResult { Data = this._productDataService.GetProductList(request) };
            }

            return new RestfulResult();
        }
コード例 #2
0
        /// <summary>
        /// 获取产品列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ExecuteResult<ProductCollectionResponse> GetProductList(GetProductListRequest request)
        {
            if (request == null)
            {
                return new ExecuteResult<ProductCollectionResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误" };
            }

            int? ruserId;
            List<int> tagIds = null;
            if (request.TagId != null)
            {
                tagIds = new List<int> { request.TagId.Value };
            }

            if (request.UserModel == null)
            {
                ruserId = null;
            }
            else
            {
                ruserId = request.UserModel.Id;
            }

            var filter = new ProductFilter
            {
                BrandId = request.BrandId,
                DataStatus = DataStatus.Normal,
                ProductName = null,
                RecommendUser = ruserId,
                TagIds = tagIds,
                Timestamp = request.Timestamp,
                TopicId = request.TopicId,
                PromotionId = request.PromotionId
            };

            ProductCollectionResponse r;
            int totalCount;

            if (request.Version > 2.09)
            {
                var produtEntities = _productRepository.Get(request.PagerRequest, out totalCount,
               request.ProductSortOrder, filter);

                var response = new ProductCollectionResponse(request.PagerRequest, totalCount)
                {
                    Products = MappingManager.ProductInfoResponseMapping(produtEntities).ToList()
                };

                r = response;
            }
            else
            {
                var p = _productRepository.GetPagedList(request.PagerRequest, out totalCount,
                                                        request.ProductSortOrder, filter);
                var response = new ProductCollectionResponse(request.PagerRequest, totalCount)
                {
                    Products = MappingManager.ProductInfoResponseMapping(p).ToList()
                };

                r = response;
            }



            var result = new ExecuteResult<ProductCollectionResponse> { Data = r };

            return result;
        }
コード例 #3
0
        public ActionResult Daren(GetProductListRequest request, [FetchUser(KeyName = "userid")]UserModel showUser)
        {
            if (System.String.Compare(request.Method, DefineRestfulMethod.List, System.StringComparison.OrdinalIgnoreCase) != 0)
            {
                return new RestfulResult { Data = new ExecuteResult { StatusCode = StatusCode.ClientError, Message = "方法错误" } };
            }

            request.UserModel = showUser;

            return new RestfulResult { Data = this._productDataService.GetProductList(request) };
        }