Beispiel #1
0
        public ActionResult Index()
        {
            if (!WebSecurity.IsAuthenticated)
            {
                RedirectToAction("Index", "Login");
            }
            int userId = WebSecurity.GetUserId(User.Identity.Name);

            var reader = context.Readers.FirstOrDefault(c => c.UserId == userId);

            int readerId;

            if (reader != null)
            {
                readerId = reader.Id;
            }

            ReaderPageModel model = new ReaderPageModel();

            model.Reader    = (ReaderDataModel)readerContext.ReaderData(userId);
            model.Libraries = readerContext.AbonentList(model.Reader.Id).Select(c => (LibraryShortModel)c).ToList();
            var dbIssues = readerContext.ReaderIssuesList(model.Reader.Id).ToList();

            if (dbIssues.Count > 5)
            {
                dbIssues.Skip(Math.Max(0, dbIssues.Count() - 5));
            }

            model.Issues = dbIssues.Select(c => (ReaderIssueModel)c).ToList();
            return(View(model));
        }
Beispiel #2
0
        public IActionResult Reader(string series, int chapter)
        {
            ViewData["Url"] = HttpContext.Request.Path;

            var model = new ReaderPageModel
            {
                Series  = series.ToLower(),
                Chapter = chapter
            };

            if (model.BadPage())
            {
                Response.Redirect("/" + series);
            }

            return(View(model));
        }