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
|
|
|
|
};
|
|
|
|
}
|
2024-02-11 01:47:58 -05:00
|
|
|
public static DiscoverySellerModel ToDiscoveryModelWithoutReviews(this UserSellerProfile sellerProfile)
|
|
|
|
{
|
|
|
|
return new DiscoverySellerModel()
|
|
|
|
{
|
|
|
|
Name = sellerProfile.User.DisplayName,
|
|
|
|
Id = sellerProfile.Id,
|
|
|
|
SocialMediaLinks = sellerProfile.SocialMediaLinks,
|
|
|
|
Biography = sellerProfile.Biography,
|
|
|
|
PrepaymentRequired = sellerProfile.PrepaymentRequired,
|
|
|
|
};
|
|
|
|
}
|
2024-02-04 01:03:43 -05:00
|
|
|
public static DiscoverySellerModel ToDiscoveryModel(this UserSellerProfile sellerProfile)
|
|
|
|
{
|
|
|
|
return new DiscoverySellerModel()
|
|
|
|
{
|
2024-02-11 01:27:23 -05:00
|
|
|
Name = sellerProfile.User.DisplayName,
|
2024-02-04 01:03:43 -05:00
|
|
|
Id = sellerProfile.Id,
|
|
|
|
SocialMediaLinks = sellerProfile.SocialMediaLinks,
|
|
|
|
Biography = sellerProfile.Biography,
|
2024-02-11 01:38:13 -05:00
|
|
|
PrepaymentRequired = sellerProfile.PrepaymentRequired,
|
2024-02-11 01:47:58 -05:00
|
|
|
AverageRating = sellerProfile.SellerServices?.Average(x=>x.Reviews?.Average(y=>y.Rating)),
|
2024-02-11 01:44:52 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|