public ActionResult GameDetails(int specificGame = default(int)) { ActionResult response = null; //Creates a new business object for use with displaying the game's rating. QuaintBLO businessAccess = new QuaintBLO(); //string picturePath = ConfigurationManager.AppSettings.Get("FilePath"); //Sets variables needed for the rating average and path to rating star pictures. decimal average = 0; string path = "/Content/RatingStars/"; if (specificGame != 0) { try { //Get a list of all comments and sends them to the business layer to be calculated. List <CommentDO> commentList = _dataAccessC.ViewGameComments(specificGame); List <CommentBO> sendComments = Mapper.ListCommentDOtoBO(commentList); //List of bytes for all ratings for a specific GameId. List <byte> ratingList = _dataAccessC.AllRatings(specificGame); //Average of all ratings for a specific game retrieved after calculations average = businessAccess.RatingAverage(ratingList); //Display the average in a whole number with one decimal place format, coverted to string. string displayAverage = average.ToString("#.#"); //Displays the number of comments a specific game has, as calculated by the business layer. int displayCommentCount = businessAccess.CommentCount(sendComments); //Get all the details for a game from the database. GameDO gameObject = _dataAccess.GameDetails(specificGame); GamePO displayGame = Mapper.GameDOtoPO(gameObject); //Display a star image representation of the rating average recieved from the calculation. if (average < 0.4m) { ViewBag.StarRating = Path.Combine(path + "0star.png"); } else if (average >= 0.5m && average < 0.9m) { ViewBag.StarRating = Path.Combine(path + "0.5star.png"); } else if (average >= 1m && average < 1.4m) { ViewBag.StarRating = Path.Combine(path + "1star.png"); } else if (average >= 1.5m && average < 1.9m) { ViewBag.StarRating = Path.Combine(path + "1.5star.png"); } else if (average >= 2m && average < 2.4m) { ViewBag.StarRating = Path.Combine(path + "2star.png"); } else if (average >= 2.5m && average < 2.9m) { ViewBag.StarRating = Path.Combine(path + "2.5star.png"); } else if (average >= 3m && average < 3.4m) { ViewBag.StarRating = Path.Combine(path + "3star.png"); } else if (average >= 3.5m && average < 3.9m) { ViewBag.StarRating = Path.Combine(path + "3.5star.png"); } else if (average >= 4m && average < 4.4m) { ViewBag.StarRating = Path.Combine(path + "4star.png"); } else if (average >= 4.5m && average < 4.9m) { ViewBag.StarRating = Path.Combine(path + "4.5star.png"); } else { ViewBag.StarRating = Path.Combine(path + "5star.png"); } //Set the calculations to a ViewBag for display within the View. ViewBag.Rating = displayAverage; ViewBag.Comments = displayCommentCount; response = View(displayGame); } catch (Exception ex) { Logger.Log(ex); //If an issue occurs, redirect to the Index of Games. response = RedirectToAction("Index", "Games"); } finally { } } else { response = RedirectToAction("Index", "Games"); } return(response); }