This commit is contained in:
Damien Ostler 2024-02-11 01:44:52 -05:00
parent d5ae99872d
commit 078488969e
2 changed files with 5 additions and 4 deletions

View File

@ -7,6 +7,6 @@ public class DiscoverySellerModel
public List<string> SocialMediaLinks { get; set; }
public string Biography { get; set; }
public bool PrepaymentRequired { get; set; }
public double AverageRating { get; set; }
public int ReviewCount { get; set; }
public double? AverageRating { get; set; }
public int? ReviewCount { get; set; }
}

View File

@ -17,6 +17,7 @@ public static class SellerProfileModelExtensions
}
public static DiscoverySellerModel ToDiscoveryModel(this UserSellerProfile sellerProfile)
{
return new DiscoverySellerModel()
{
Name = sellerProfile.User.DisplayName,
@ -24,8 +25,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 = sellerProfile.SellerServices?.Average(x=>x.Reviews.Average(y=>y.Rating)),
ReviewCount = sellerProfile.SellerServices?.Sum(x=>x.Reviews.Count)
};
}
public static UserSellerProfile ToModel(this SellerProfileModel sellerProfile, UserSellerProfile existingSellerProfile)