public async ValueTask UpdateById(ReviewsContext context, int id) { var review = await context.Reviews.FirstAsync(r => r.Id == id); review.Title = Title; review.Description = Description; }
public async ValueTask Update(ReviewsContext context, int accountId, int id) { var review = await context.Reviews.FirstAsync(r => r.Id == id && r.AccountId == accountId); review.Rating = Rating; review.Title = Title; review.Description = Description; review.Updated = DateTime.UtcNow; }
public async ValueTask Read(ReviewsContext context, FilterRequest filter, int accountId) { Reviews = await context.Reviews .AsNoTracking() .Where(review => review.AccountId == accountId) .OrderByDescending(review => review.Created) .Skip(filter.Offset) .Take(filter.Limit) .Select(review => new ReadReviewsResponseItem(review)) .ToListAsync(); }
public async ValueTask Create(ReviewsContext context, int accountId, int mangaId) { var review = new Review { Rating = Rating, Title = Title, Description = Description, AccountId = accountId, MangaId = mangaId, Created = DateTime.UtcNow }; await context.Reviews.AddAsync(review); }
public async ValueTask ReadById(ReviewsContext context, FilterRequest filter, int mangaId) { Rating = await context.Reviews .Select(r => r.Rating) .AverageAsync(); Reviews = await context.Reviews .AsNoTracking() .Where(review => review.MangaId == mangaId) .OrderByDescending(review => review.Created) .Skip(filter.Offset) .Take(filter.Limit) .Select(review => new ReadByIdReviewsResponseItem(review)) .ToListAsync(); }
public async ValueTask Delete(ReviewsContext context, int accountId) { var review = await context.Reviews.FirstAsync(r => r.Id == Id && r.AccountId == accountId); context.Reviews.Remove(review); }
public ReviewsController(ReviewsContext context) { this.context = context; }
public async ValueTask DeleteById(ReviewsContext context) { var review = await context.Reviews.FirstAsync(r => r.Id == Id); context.Reviews.Remove(review); }