mirror of
				https://github.com/D4M13N-D3V/comissions-app-core-api.git
				synced 2025-10-31 01:25:27 +00:00 
			
		
		
		
	fix: update average rating information to be returned on seller endpoint for discover
This commit is contained in:
		
							parent
							
								
									fe2aa82935
								
							
						
					
					
						commit
						d5ae99872d
					
				| @ -38,6 +38,7 @@ public class DiscoveryController : Controller | ||||
|     public async Task<IActionResult> GetSeller(int sellerId) | ||||
|     { | ||||
|         var seller = await _dbContext.UserSellerProfiles | ||||
|             .Include(x=>x.SellerServices).ThenInclude(x=>x.Reviews) | ||||
|             .Include(x=>x.User) | ||||
|             .FirstOrDefaultAsync(x=>x.Id==sellerId); | ||||
|         if(seller==null) | ||||
|  | ||||
| @ -7,4 +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; } | ||||
| } | ||||
| @ -23,7 +23,9 @@ public static class SellerProfileModelExtensions | ||||
|             Id = sellerProfile.Id, | ||||
|             SocialMediaLinks = sellerProfile.SocialMediaLinks, | ||||
|             Biography = sellerProfile.Biography, | ||||
|             PrepaymentRequired = sellerProfile.PrepaymentRequired | ||||
|             PrepaymentRequired = sellerProfile.PrepaymentRequired, | ||||
|             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) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Damien Ostler
						Damien Ostler