public Details(Product product, CommentContext commentDb, Rating2Context ratingContext, string userName) { Product = product; CommentDb = commentDb; RatingContext = ratingContext; Rating = RatingContext.FindRating(userName, Product.ProductId); SetProductComments(); }
public int Rating { get; set; } //ocena public static ProductVM ConvertToVM(Product source) { ProductVM target = new ProductVM(); target.ProductId = source.ProductId; target.SupplierId = source.SupplierId; target.ProductName = source.ProductName; target.ProductDescription = source.ProductDescription; target.Quantity = source.Quantity; target.AddDate = source.AddDate; target.Category = source.Category; target.Price = source.Price; target.Unit = source.Unit; target.Tags = source.Tags; target.PhotoImageFileName = source.PhotoImageFileName; target.PhotoImageMimeType = source.PhotoImageMimeType; target.Rating = source.RatingNumber != 0 ? source.RatingSum / source.RatingNumber : 0; return target; }