Ejemplo n.º 1
0
        /// <summary>
        /// 记录日志列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult UserLogs(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(BadRequest());
            }

            #region 构造参数

            var paramArr = id.Split('-');
            if (paramArr.Length != 2)
            {
                return(BadRequest());
            }
            var page   = Convert.ToInt32(paramArr[1]);
            var codeId = Convert.ToInt32(paramArr[0]);
            if (codeId != (int)EmLogCode.登录 && codeId != (int)EmLogCode.积分)
            {
                return(BadRequest());
            }
            page = page <= 0 ? 1 : page;

            var pageOption = new PyPagerOption {
                CurrentPage     = page,
                PageSize        = 15,
                Total           = 0,
                RouteUrl        = $"/UserCenter/UserLogs/{codeId}",
                StyleNum        = 1,
                JoinOperateCode = "-"
            };

            #endregion

            var userLogs = _db.ToUserLog
                           .Where(b => b.UserId == _MyUserInfo.Id && b.CodeId == codeId)
                           .AsEnumerable();

            pageOption.Total = userLogs.Count();
            userLogs         = userLogs.OrderByDescending(b => b.Id)
                               .Skip((pageOption.CurrentPage - 1) * pageOption.PageSize)
                               .Take(pageOption.PageSize)
                               .ToList();
            ViewBag.PagerOption = pageOption;

            var userLog = new ToUserLog {
                CodeId = codeId,
                Des    = $"{Enum.GetName(typeof(EmLogCode), codeId)}记录"
            };
            ViewData["userLog"] = userLog;
            return(View(userLogs));
        }
Ejemplo n.º 2
0
        public IActionResult Module(string id)
        {
            #region 构造参数
            var paramArr = id.Split('-');
            if (paramArr.Length != 2)
            {
                return(BadRequest());
            }
            var page     = Convert.ToInt32(paramArr[1]);
            var moduleId = Convert.ToInt32(paramArr[0]);

            var module = _db.ToModule
                         .SingleOrDefault(b => b.Id == moduleId);

            if (module == null)
            {
                return(BadRequest());
            }

            page = page <= 0 ? 1 : page;

            var pageOption = new PyPagerOption {
                CurrentPage     = page,
                PageSize        = 15,
                Total           = 0,
                RouteUrl        = $"UserCenter/Modules/{moduleId}",
                StyleNum        = 1,
                JoinOperateCode = "-"
            };
            #endregion
            var contents = _db.ToContent
                           .Where(b => b.UserId == _MyUserInfo.Id && b.ModuleId == moduleId && b.Status != (int)EmContentStatus.除)
                           .AsEnumerable();
            pageOption.Total = contents.Count();
            contents         = contents.OrderByDescending(b => b.CreateTime)
                               .Skip((pageOption.CurrentPage - 1) * pageOption.PageSize)
                               .Take(pageOption.PageSize).ToList();

            ViewData["module"]  = module;
            ViewBag.PagerOption = pageOption;
            return(View(contents));
        }