コード例 #1
0
        public ActionResult Issue(int id)
        {
            var result = comicService.GetComic(id);

            if (result.GenreId.HasValue)
            {
                var genre = comicService.GetGenres(Convert.ToInt32(result.GenreId));
                result.GenreDescription = genre.FirstOrDefault().Description;
            }

            result.Rating = Math.Round(comicService.GetRating(result.Id), 0, MidpointRounding.AwayFromZero);

            bool isAuthorized = Session["Authorized"] != null ? (bool)Session["Authorized"] : false;

            if (isAuthorized)
            {
                var userName   = (string)Session["UserName"];
                var userRating = comicService.GetUserRating(userName, result.Id);
                ViewBag.UserRating = Math.Round(userRating, 0, MidpointRounding.AwayFromZero);
            }

            return(View(result));
        }