Пример #1
0
        public ActionResult Publish()
        {
            string userId = Com.Cos.Common.Public.GetLoginUid().ToString();
            int    totalRecord;
            var    exchanges = _exchangeService.FindPageList(1, 5, out totalRecord, e => e.UserId == userId, "AddTime", false).ToList();

            ViewBag.PageIndex   = 1;
            ViewBag.PageSize    = 5;
            ViewBag.TotalRecord = totalRecord;
            for (int i = 0; i < exchanges.Count; i++)
            {
                exchanges[i].Examine = _exchangeExamineService.Find(exchanges[i].Examine.ToInt32()).ExamineName;
                string coverId = exchanges[i].Cover;
                if (string.IsNullOrEmpty(coverId))  //如果没有封面,则取第一张图片
                {
                    string   imgList = exchanges[i].ImgList;
                    string[] imgs    = imgList.Split(',');
                    coverId = imgs[0];
                }
                string cover = TWEBURL.WEB_URL_IMG + _imgService.Find(coverId.ToInt32())?.ImgSmallUrl;
                exchanges[i].Cover = cover;
            }
            ViewBag.Exchanges = exchanges;
            return(View("Publish"));
        }
Пример #2
0
        /// <summary>
        /// 获得列表页数据
        /// </summary>
        /// <param name="page">当前页</param>
        /// <param name="examineId">兑换状态id</param>
        /// <param name="classId">兑换分类id</param>
        /// <returns></returns>
        private List <ExchangeViewModel> GetExchange(int page, string examineId, string classId)
        {
            int totalRecord;
            var excs = _exchangeService.FindPageList(page, 8, examineId, classId, out totalRecord);

            ViewBag.PageIndex   = page;
            ViewBag.PageSize    = 6;
            ViewBag.TotalRecord = totalRecord;
            List <ExchangeViewModel> exchangeList = new List <ExchangeViewModel>();

            foreach (var exc in excs)
            {
                Type   type    = exc.GetType();
                string coverId = type.GetProperty("Cover").GetValue(exc, null);
                if (string.IsNullOrEmpty(coverId))  //如果没有封面,则取第一张图片
                {
                    string   imgList = type.GetProperty("ImgList").GetValue(exc, null);
                    string[] imgs    = imgList.Split(',');
                    coverId = imgs[0];
                }
                string cover = _imgService.Find(coverId.ToInt32())?.ImgSmallUrl;

                exchangeList.Add(new ExchangeViewModel
                {
                    Id            = type.GetProperty("Id").GetValue(exc, null),
                    Cover         = TWEBURL.WEB_URL_IMG + cover,
                    Nickname      = type.GetProperty("Nickname").GetValue(exc, null),
                    Portrait      = TWEBURL.WEB_URL_IMG + type.GetProperty("Portrait").GetValue(exc, null),
                    Title         = type.GetProperty("Title").GetValue(exc, null),
                    ItemName      = type.GetProperty("ItemName").GetValue(exc, null),
                    ItemCharacter = type.GetProperty("ItemCharacter").GetValue(exc, null),
                    Constitute    = type.GetProperty("Constitute").GetValue(exc, null),
                    Source        = type.GetProperty("Source").GetValue(exc, null),
                    Price         = type.GetProperty("Price").GetValue(exc, null),
                    ClassId       = type.GetProperty("ClassId").GetValue(exc, null),
                    Describe      = type.GetProperty("Describe").GetValue(exc, null),
                    //Valuation1 = type.GetProperty("Valuation1").GetValue(exc, null),
                    //Valuation2 = type.GetProperty("Valuation2").GetValue(exc, null),
                    //Valuation3 = type.GetProperty("Valuation3").GetValue(exc, null),
                    //Certificate = type.GetProperty("Certificate").GetValue(exc, null),
                    ImgList = type.GetProperty("ImgList").GetValue(exc, null),
                    AddTime = type.GetProperty("AddTime").GetValue(exc, null)
                });
            }
            return(exchangeList);
        }