Example #1
0
        /// <summary>
        /// 获取优惠券种类
        /// </summary>
        /// <returns>list列表</returns>
        public HttpResponseMessage Coupons()
        {
            var Con = new OtherCouponCategorySearchCondition
            {
                OrderBy = EnumOtherCouponCategorySearchOrderBy.OrderById
            };
            var list = _otherCouponCategoryService.GetCouponCategoriesByCondition(Con).Select(p => new
            {
                p.Id,
                p.BrandId,
                p.Name,
                p.ReMark,
                p.Price,
                p.Count
            }).ToList().Select(pp => new CouponCategoryModel
            {
                Id               = pp.Id,
                Name             = pp.Name,
                Price            = pp.Price,
                Count            = pp.Count,
                ReMark           = pp.ReMark,
                BrandImg         = _productBrandService.GetProductBrandById(pp.BrandId).Bimg,
                SubTitle         = _productBrandService.GetProductBrandById(pp.BrandId).SubTitle,
                ProductParamater = _productBrandService.GetProductBrandById(pp.BrandId).ParameterEntities.ToDictionary(k => k.Parametername, v => v.Parametervaule)
            });

            return(PageHelper.toJson(list));
        }
        /// <summary>
        /// 优惠劵显示列表
        /// </summary>
        /// <returns></returns>
        public ActionResult OtherCoupons()
        {
            var conConditon = new OtherCouponCategorySearchCondition
            {
                // ClassId = classId,
                OrderBy = EnumOtherCouponCategorySearchOrderBy.OrderById
            };
            var list = _otherCouponCategoryService.GetCouponCategoriesByCondition(conConditon).Select(p => new
            {
                p.Id,
                p.BrandId,
                p.Name,
                p.ReMark,
                p.Price,
                p.Count
            }).ToList().Select(pp => new CouponCategoryModel
            {
                Id               = pp.Id,
                Name             = pp.Name,
                Price            = pp.Price,
                Count            = pp.Count,
                ReMark           = pp.ReMark,
                BrandId          = pp.BrandId,
                BrandImg         = _productBrandService.GetProductBrandById(pp.BrandId).Bimg,
                SubTitle         = _productBrandService.GetProductBrandById(pp.BrandId).SubTitle,
                ProductParamater = _productBrandService.GetProductBrandById(pp.BrandId).ParameterEntities.ToDictionary(k => k.Parametername, v => v.Parametervaule)
            });

            return(View(list));
        }
        public IQueryable <OtherCouponCategory> GetCouponCategoriesByCondition(OtherCouponCategorySearchCondition condition)
        {
            var query = _repository.Table;

            if (condition.BrandId.HasValue)
            {
                query = query.Where(c => c.BrandId == condition.BrandId);
            }
            if (!string.IsNullOrEmpty(condition.Name))
            {
                query = query.Where(c => condition.Name == c.Name);
            }
            if (condition.ClassId.HasValue)
            {
                query = query.Where(c => condition.ClassId == c.ClassId);
            }
            if (condition.OrderBy.HasValue)
            {
                switch (condition.OrderBy.Value)
                {
                case EnumOtherCouponCategorySearchOrderBy.OrderById:
                    query = condition.IsDescending ? query.OrderByDescending(q => q.Id) : query.OrderBy(q => q.Id);
                    break;
                }
            }
            else
            {
                query = query.OrderBy(q => q.Id);
            }
            if (condition.Page.HasValue && condition.PageSize.HasValue)
            {
                query = query.Skip((condition.Page.Value - 1) * condition.PageSize.Value).Take(condition.PageSize.Value);
            }
            return(query);
        }
        public int GetCouponCategoriesCountByCondition(OtherCouponCategorySearchCondition condition)
        {
            var query = _repository.Table;

            if (condition.BrandId.HasValue)
            {
                query = query.Where(c => c.BrandId == condition.BrandId);
            }
            if (!string.IsNullOrEmpty(condition.Name))
            {
                query = query.Where(c => condition.Name == c.Name);
            }
            if (condition.ClassId.HasValue)
            {
                query = query.Where(c => condition.ClassId == c.ClassId);
            }
            return(query.Count());
        }
Example #5
0
        public HttpResponseMessage Index(int page, int pageSize, string name = null)
        {
            var condition = new OtherCouponCategorySearchCondition
            {
                Name     = name,
                Page     = page,
                PageSize = pageSize,
                OrderBy  = EnumOtherCouponCategorySearchOrderBy.OrderById
            };
            var couponCategory = _otherCouponCategoryService.GetCouponCategoriesByCondition(condition).Select(p => new
            {
                p.Id,
                p.Name,
                p.Count,
                p.Price,
                p.ReMark
            }).ToList();
            var count = _otherCouponCategoryService.GetCouponCategoriesCountByCondition(condition);

            return(PageHelper.toJson(new { List = couponCategory, TotalCount = count, Condition = condition }));
        }