public ActionResult Details(int id)
{
var userId = this.User.Identity.GetUserId();
var viewModel = this.Data.Laptops.All()
.Where(x => x.ID == id)
.Select(x => new LaptopDetailsViewModel
{
Id = x.ID,
AdditionalParts = x.AdditionalParts,
Comments = x.Comments.Select(c => new CommentViewModel { AuthorUserName = c.Author.UserName, Content = c.Content }),
Description = x.Description,
HardDiskSize = x.HardDiskSize,
ImageUrl = x.ImageUrl,
ManufacturerName = x.Manufacturer.Name,
Model = x.Model,
MonitorSize = x.MonitorSize,
Price = x.Price,
RamMemorySize = x.RamMemorySize,
Weight = x.Weight,
VotesCount = x.Votes.Count(),
UserCanVote = !x.Votes.Any(v => v.VotedById == userId)
}).FirstOrDefault();
return View(viewModel);
}