diff --git a/src/comissions.app.api/Models/SellerProfile/SellerProfileModelExtensions.cs b/src/comissions.app.api/Models/SellerProfile/SellerProfileModelExtensions.cs index cf7a0d7..042b710 100644 --- a/src/comissions.app.api/Models/SellerProfile/SellerProfileModelExtensions.cs +++ b/src/comissions.app.api/Models/SellerProfile/SellerProfileModelExtensions.cs @@ -28,6 +28,9 @@ public static class SellerProfileModelExtensions } public static DiscoverySellerModel ToDiscoveryModel(this UserSellerProfile sellerProfile) { + var reviews = sellerProfile.SellerServices.SelectMany(x=>x.Reviews).Select(x=>x.ToDiscoveryModel()); + var reviewAverage = reviews.Average(x=>x.Rating); + return new DiscoverySellerModel() { Name = sellerProfile.User.DisplayName, @@ -35,8 +38,8 @@ public static class SellerProfileModelExtensions SocialMediaLinks = sellerProfile.SocialMediaLinks, Biography = sellerProfile.Biography, PrepaymentRequired = sellerProfile.PrepaymentRequired, - AverageRating = sellerProfile.SellerServices?.Average(x=>x.Reviews?.Average(y=>y.Rating)), - ReviewCount = sellerProfile.SellerServices?.Sum(x=>x.Reviews.Count) + AverageRating =reviewAverage, + ReviewCount = reviews.Count() }; } public static UserSellerProfile ToModel(this SellerProfileModel sellerProfile, UserSellerProfile existingSellerProfile)