39 lines
1.6 KiB
C#
Raw Normal View History

2024-02-04 01:03:43 -05:00
using ArtPlatform.Database.Entities;
using comissions.app.api.Models.Discovery;
using comissions.app.database.Entities;
namespace comissions.app.api.Models.SellerProfile;
public static class SellerProfileModelExtensions
{
public static SellerProfileModel ToModel(this UserSellerProfile sellerProfile)
{
return new SellerProfileModel()
{
SocialMediaLinks = sellerProfile.SocialMediaLinks,
Biography = sellerProfile.Biography,
PrepaymentRequired = sellerProfile.PrepaymentRequired
};
}
public static DiscoverySellerModel ToDiscoveryModel(this UserSellerProfile sellerProfile)
{
2024-02-11 01:44:52 -05:00
2024-02-04 01:03:43 -05:00
return new DiscoverySellerModel()
{
Name = sellerProfile.User.DisplayName,
2024-02-04 01:03:43 -05:00
Id = sellerProfile.Id,
SocialMediaLinks = sellerProfile.SocialMediaLinks,
Biography = sellerProfile.Biography,
PrepaymentRequired = sellerProfile.PrepaymentRequired,
2024-02-11 01:44:52 -05:00
AverageRating = sellerProfile.SellerServices?.Average(x=>x.Reviews.Average(y=>y.Rating)),
ReviewCount = sellerProfile.SellerServices?.Sum(x=>x.Reviews.Count)
2024-02-04 01:03:43 -05:00
};
}
public static UserSellerProfile ToModel(this SellerProfileModel sellerProfile, UserSellerProfile existingSellerProfile)
{
existingSellerProfile.SocialMediaLinks = sellerProfile.SocialMediaLinks;
existingSellerProfile.Biography = sellerProfile.Biography;
existingSellerProfile.PrepaymentRequired = sellerProfile.PrepaymentRequired;
return existingSellerProfile;
}
}