示例#1
0
        public async Task <ActionResult <IEnumerable <Commodity> > > GetCommodities()
        {
            try
            {
                var commodities = await mc_CommodityRepository.GetCommodities(string.Empty);

                return(Ok(commodities));
            }
            catch (Exception exception)
            {
                string message = "Error occurred in CommodityController.GetCommodity" + Environment.NewLine;
                message += exception.Message;
                return(StatusCode(StatusCodes.Status500InternalServerError, message));
            }
        }
示例#2
0
        public ViewResult Index()
        {
            var getCommoditiesResult = mc_CommodityRepository.GetCommodities("");
            var commodities          = getCommoditiesResult.Result as List <Commodity>;

            var retCommodityGroupsResult = mc_CommodityRepository.GetCommodityGroups("");
            var commodityGroups          = retCommodityGroupsResult.Result as List <CommodityGroup>;

            var commodityViewModels     = BuildCommodityViewModels(commodityGroups, commodities) as List <CommodityViewModel>;
            var commodityIndexViewModel = new CommodityIndexViewModel(commodityViewModels, commodityGroups);

            return(View(commodityIndexViewModel));
        }
示例#3
0
 public IActionResult ShowCommodity(int page, int limit)
 {
     try
     {
         //获取所有评价管理信息
         var list = _commodityRepository.GetCommodities();
         //总条数
         int count = list.Count;
         //分页后的数据
         list = list.Skip((page - 1) * limit).Take(limit).ToList();
         //返回
         return(Ok(new { msg = "", code = 0, data = list, count = count }));
     }
     catch (Exception)
     {
         throw;
     }
 }