/// <summary>
        /// 生成动态操作链接
        /// </summary>       
        private static MvcHtmlString PointMessage(this HtmlHelper htmlHelper, long userId)
        {
            PointService pointService = new PointService();
            IEnumerable<PointCategory> pointCategories = pointService.GetPointCategories();

            htmlHelper.ViewData["ExperiencePoints"] = pointCategories.FirstOrDefault(n => n.CategoryKey.Equals("ExperiencePoints")).CategoryName;
            htmlHelper.ViewData["ReputationPoints"] = pointCategories.FirstOrDefault(n => n.CategoryKey.Equals("ReputationPoints")).CategoryName;
            htmlHelper.ViewData["TradePoints"] = pointCategories.FirstOrDefault(n => n.CategoryKey.Equals("TradePoints")).CategoryName;

            PointRecord pointRecord = pointService.GetUserLastestRecord(userId);
            htmlHelper.ViewData["PointRecord"] = pointRecord;
            return htmlHelper.DisplayForModel("PointMessage");
        }
예제 #2
0
        public ActionResult ManagePointRecords(int? pageIndex, int pageSize = 20)
        {
            PointService pointService = new PointService();
            pageResourceManager.InsertTitlePart("管理积分记录");

            IEnumerable<PointCategory> pointCategories = pointService.GetPointCategories();
            ViewData["traPoint"] = pointCategories.FirstOrDefault(n => n.CategoryKey.Equals("TradePoints")).CategoryName;
            ViewData["expPoint"] = pointCategories.FirstOrDefault(n => n.CategoryKey.Equals("ExperiencePoints")).CategoryName;
            ViewData["prePoint"] = pointCategories.FirstOrDefault(n => n.CategoryKey.Equals("ReputationPoints")).CategoryName;

            bool? isIncome = null;
            DateTime? startDate = null;
            DateTime? endDate = null;
            string isSystemData = Request.QueryString["isSystemData"];
            IEnumerable<long> userIds = Request.QueryString.Gets<long>("userId");
            long? userId = null;
            string pointItemName = Request.QueryString.GetString("pointItemName", null);
            bool isCheck = false;
            isIncome = Request.QueryString.Get<bool?>("incomelist");

            if (isSystemData != null && !isSystemData.Equals("false"))
            {
                userId = 0;
                isCheck = true;
            }
            else if (userIds != null && userIds.Count() > 0)
            {
                userId = userIds.FirstOrDefault();
            }
            ViewData["isCheck"] = isCheck;

            if (Request.QueryString.Get<DateTime>("startdate") != DateTime.MinValue)
                startDate = Request.QueryString.Get<DateTime>("startDate");

            if (Request.QueryString.Get<DateTime>("enddate") != DateTime.MinValue)
                endDate = Request.QueryString.Get<DateTime>("endDate");
            if (startDate.HasValue && endDate.HasValue && startDate.Value > endDate.Value)
            {
                DateTime? changDate = startDate;
                startDate = endDate;
                endDate = changDate;
            }
            if (endDate.HasValue)
                endDate = endDate.Value.AddDays(1).AddMilliseconds(-1);

            Dictionary<bool, string> income = new Dictionary<bool, string> { { true, "收入" }, { false, "支出" } };
            ViewData["incomeList"] = new SelectList(income.Select(n => new { text = n.Value.ToString(), value = n.Key.ToString().ToLower() }), "value", "text", isIncome);

            ViewData["userId"] = userId;

            PagingDataSet<PointRecord> pointRecords = pointService.GetPointRecords(userId, isIncome, pointItemName, startDate, endDate, pageSize, pageIndex ?? 1);

            Dictionary<long, string> displayNameDic = new Dictionary<long, string>();
            foreach (var item in pointRecords)
            {
                if (userService.GetUser(item.UserId) != null && userService.GetUser(item.UserId).DisplayName != null)
                    displayNameDic[item.UserId] = userService.GetUser(item.UserId).DisplayName;
            }
            ViewData["displayNameDic"] = displayNameDic;
            return View(pointRecords);
        }