- Timestamp:
- 07/10/22 10:27:45 (2 years ago)
- Branches:
- master
- Children:
- a26f6a1
- Parents:
- cc4db18
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Services/RestaurantService.cs
rcc4db18 r899b19d 32 32 { 33 33 RestaurantResponse res = await _context.Restoraunts 34 .Include(x => x.Menu) 35 .Include(x => x.Reviews).ThenInclude(x => x.User) 34 36 .Select(x => new RestaurantResponse() 35 37 { … … 44 46 Description = x.Description, 45 47 Price = x.Price 46 }).ToList() 48 }).ToList(), 49 Reviews = x.Reviews.OrderByDescending(x => x.CreatedAt).Select(x => new ReviewResponse() 50 { 51 Id = x.Id, 52 Title = x.Title, 53 Description = x.Description, 54 Stars = x.Stars, 55 CreatedAt = x.CreatedAt, 56 Username = x.User == null ? "Anonymous" : x.User.Email 57 }).ToList(), 58 AverageReview = x.Reviews.Count>0 ? x.Reviews.Select(x => x.Stars).Average() : 0 47 59 }) 48 60 .FirstOrDefaultAsync();
Note:
See TracChangeset
for help on using the changeset viewer.