Changeset 63f5ced for resTools_backend/backend/Services/ReviewService.cs
- Timestamp:
- 08/24/22 17:11:52 (2 years ago)
- Branches:
- master
- Children:
- d86edb7
- Parents:
- a569b7c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Services/ReviewService.cs
ra569b7c r63f5ced 9 9 { 10 10 public Task AddReview(CreateReviewRequest review, int userId); 11 public Task<List<ReviewResponse>> GetReviews(int page, int pageSize); 12 public Task<int> GetCount(); 11 13 } 12 14 public class ReviewService : IReviewService … … 38 40 await _context.SaveChangesAsync(); 39 41 } 42 43 public async Task<int> GetCount() 44 { 45 return await _context.Reviews.CountAsync(); 46 } 47 48 public async Task<List<ReviewResponse>> GetReviews(int page, int pageSize) 49 { 50 return await _context.Reviews 51 .Include(x => x.User) 52 .OrderByDescending(x => x.CreatedAt) 53 .Skip(page * pageSize) 54 .Take(pageSize) 55 .Select(x => new ReviewResponse() 56 { 57 CreatedAt = x.CreatedAt, 58 Description = x.Description, 59 Id = x.Id, 60 Stars = x.Stars, 61 Title = x.Title, 62 Username = x.User == null ? "Anonymous" : x.User.Email 63 }) 64 .ToListAsync(); 65 } 40 66 } 41 67 }
Note:
See TracChangeset
for help on using the changeset viewer.