mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-14 10:04:55 +00:00
fixed how ratings are averaged
This commit is contained in:
parent
40aa399549
commit
1d02758d71
@ -28,6 +28,9 @@ public static class SellerProfileModelExtensions
|
|||||||
}
|
}
|
||||||
public static DiscoverySellerModel ToDiscoveryModel(this UserSellerProfile sellerProfile)
|
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()
|
return new DiscoverySellerModel()
|
||||||
{
|
{
|
||||||
Name = sellerProfile.User.DisplayName,
|
Name = sellerProfile.User.DisplayName,
|
||||||
@ -35,8 +38,8 @@ public static class SellerProfileModelExtensions
|
|||||||
SocialMediaLinks = sellerProfile.SocialMediaLinks,
|
SocialMediaLinks = sellerProfile.SocialMediaLinks,
|
||||||
Biography = sellerProfile.Biography,
|
Biography = sellerProfile.Biography,
|
||||||
PrepaymentRequired = sellerProfile.PrepaymentRequired,
|
PrepaymentRequired = sellerProfile.PrepaymentRequired,
|
||||||
AverageRating = sellerProfile.SellerServices?.Average(x=>x.Reviews?.Average(y=>y.Rating)),
|
AverageRating =reviewAverage,
|
||||||
ReviewCount = sellerProfile.SellerServices?.Sum(x=>x.Reviews.Count)
|
ReviewCount = reviews.Count()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static UserSellerProfile ToModel(this SellerProfileModel sellerProfile, UserSellerProfile existingSellerProfile)
|
public static UserSellerProfile ToModel(this SellerProfileModel sellerProfile, UserSellerProfile existingSellerProfile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user