public ProductCompareViewModel GetForAddToCompare(long id) { var product = _products.Where(a => a.Id == id).Include(a => a.Category).FirstOrDefault(); var attributes = _valueService.GetAttValueOfProduct(id); return(new ProductCompareViewModel { Attributes = attributes, ProductName = product.Name, ImagePath = product.PrincipleImagePath, AvrageRate = product.Rate.AverageRating, Description = product.Description, ProductId = product.Id, TotalRaters = product.Rate.TotalRaters ?? 0, Price = product.Price, FreeSend = product.IsFreeShipping, Discount = product.ApplyCategoryDiscount ? product.DiscountPercent + product.Category.DiscountPercent : product.DiscountPercent, }); }