예제 #1
0
        public ActionResult List(GoodsQuery query)
        {
            var list   = this.GoodsRepository.GetList(query);
            var data   = list.Data.Select(c => GoodsModel.From(c)).ToList();
            var result = new { total = list.RecordCount, rows = data };

            return(Json(result));
        }
예제 #2
0
        public ActionResult GetGoods(int id)
        {
            var goods = this.GoodsRepository.Get(id);

            if (goods != null)
            {
                return(JsonSuccess(GoodsModel.From(goods)));
            }

            return(JsonError("未找到商品"));
        }
예제 #3
0
        public ActionResult Detail(int id)
        {
            Goods item = this.GoodsRepository.Get(id);

            if (item == null)
            {
                item = new Goods();
            }

            ViewData["Category"] = this.GoodsTypeRepository.GetGoodsTypes(item.Id);

            return(View(GoodsModel.From(item)));
        }
예제 #4
0
        public ActionResult GetByPinyin(string q)
        {
            if (q.IsNullOrEmpty())
            {
                return(Json(new { total = 0, rows = new List <GoodsType>() }));
            }

            var list = this.GoodsRepository.GetAll(new GoodsQuery {
                Pinyin = q
            });
            var data   = list.Select(c => GoodsModel.From(c)).ToList();
            var result = new { total = list.Count, rows = data };

            return(Json(result));
        }