public IHttpResponse Details(IHttpRequest httpRequest) { if (!this.IsLoggedIn(httpRequest)) { return(this.Redirect("../Users/Login")); } using (var db = new RunesDbContext()) { var albumId = httpRequest.QueryData["id"].ToString(); var albumFromDb = db.Albums.Find(albumId); var albumPrice = db.Tracks.Where(track => track.Album.Id == albumFromDb.Id).Sum(track => track.Price); albumPrice = (albumPrice * 87) / 100; if (albumFromDb == null) { return(this.Redirect("All")); } //this.ViewData["Album"] = albumFromDb.AlbumsDetailsToHtml(); this.ViewData["Cover"] = WebUtility.UrlDecode(albumFromDb.Cover); this.ViewData["Price"] = $"{albumPrice:F2}"; this.ViewData["Name"] = albumFromDb.Name; this.ViewData["AlbumId"] = albumId; if (!db.Tracks.Any()) { this.ViewData["Tracks"] = "There are currently no tracks!"; } else { this.ViewData["Tracks"] = db.AlbumsDetailsToHtml(albumFromDb); } albumFromDb.Price = albumPrice; db.Update(albumFromDb); db.SaveChanges(); } return(this.View()); }