public async Task <PagedList <Review> > GetReviews(ReviewParams revParams) { var reviews = _context.Reviews.Include(rev => rev.Reviewer).AsQueryable(); if (revParams.ReviewerId != 0 && revParams.ReviewerId != -1) { reviews = reviews.Where(rev => rev.ReviewerId == revParams.ReviewerId); } if (revParams.DateFrom != null && revParams.DateFrom != DateTime.MinValue) { reviews = reviews.Where(rev => rev.ReviewDate >= revParams.DateFrom); } if (revParams.DateTo != null && revParams.DateTo != DateTime.MinValue) { reviews = reviews.Where(rev => rev.ReviewDate <= revParams.DateTo); } if (!string.IsNullOrWhiteSpace(revParams.BookAsin)) { reviews = reviews.Where(rev => rev.BookAsin == revParams.BookAsin); } if (!string.IsNullOrWhiteSpace(revParams.Country)) { reviews = reviews.Where(rev => rev.Country.ToLower() == revParams.Country.ToLower()); } if (!string.IsNullOrWhiteSpace(revParams.PenName)) { reviews = reviews.Where(rev => rev.PenName.ToLower().Contains(revParams.PenName.ToLower())); } reviews = reviews.OrderByDescending(rev => rev.ReviewDate); return(await PagedList <Review> .CreateAsync(reviews, revParams.PageNumber, revParams.PageSize)); }
public async Task <List <Review> > GetReviewsForDelete(ReviewParams revParams) { var reviews = _context.Reviews.Include(rev => rev.Reviewer).AsQueryable(); if (revParams.ReviewerId != 0 && revParams.ReviewerId != -1) { reviews = reviews.Where(rev => rev.ReviewerId == revParams.ReviewerId); } if (revParams.DateFrom != null && revParams.DateFrom != DateTime.MinValue) { reviews = reviews.Where(rev => rev.ReviewDate >= revParams.DateFrom); } if (revParams.DateTo != null && revParams.DateTo != DateTime.MinValue) { reviews = reviews.Where(rev => rev.ReviewDate <= revParams.DateTo); } if (!string.IsNullOrWhiteSpace(revParams.BookAsin)) { reviews = reviews.Where(rev => rev.BookAsin == revParams.BookAsin); } if (!string.IsNullOrWhiteSpace(revParams.Country)) { reviews = reviews.Where(rev => rev.Country.ToLower() == revParams.Country.ToLower()); } if (!string.IsNullOrWhiteSpace(revParams.PenName)) { reviews = reviews.Where(rev => rev.PenName.ToLower().Contains(revParams.PenName.ToLower())); } return(await reviews.ToListAsync()); }
public async Task <PagedList <Review> > GetReviewsForUser(int userId, ReviewParams reviewParams) { var reviews = _context.Reviews.Where(u => u.UserId == userId) .OrderByDescending(d => d.DateAdded); return(await PagedList <Review> .CreateAsync(reviews, reviewParams.PageNumber, reviewParams.PageSize)); }
public async Task <PagedList <Review> > GetReviewsForUser(ReviewParams reviewParams) { var most_recent = "most_recent"; var reviews = _context.Reviews.AsQueryable(); if (string.IsNullOrEmpty(reviewParams.OrderBy)) { reviewParams.OrderBy = most_recent; } switch (reviewParams.OrderBy.ToLower()) { case "most_recent": reviews = reviews.OrderByDescending(u => u.CreatedDate); break; case "top_reviews": reviews = reviews.OrderByDescending(u => u.Stars); break; case "low_review": reviews = reviews.OrderByDescending(u => u.Stars); break; } return(await PagedList <Review> .CreateAsync(reviews, reviewParams.PageNumber, reviewParams.PageSize)); }
public async Task <PagedList <Review> > GetMoreReviews(ReviewParams reviewParams) { var reviews = _context.Reviews.Where(r => r.IsApproved == true) .OrderByDescending(d => d.DateAdded); return(await PagedList <Review> .CreateAsync(reviews, reviewParams.PageNumber, reviewParams.PageSize)); }
public async Task <ActionResult <IEnumerable <Review> > > GetUserLikes([FromQuery] ReviewParams reviewParams) { reviewParams.UserId = User.GetUserId(); var result = await _reviewService.GetUserReviews(reviewParams); Response.AddPaginationHeader(result.CurrentPage, result.PageSize, result.TotalCount, result.TotalPages); return(Ok(result)); }
public async Task <PagedList <Review> > GetUserReviews(ReviewParams reviewParams) { // var books = repository.context.Books.OrderBy(x=>x.Title).AsQueryable(); var reviews = repository.context.Reviews.AsQueryable(); reviews = reviews.Where(r => r.AccountId == reviewParams.UserId); return(await PagedList <Review> .CreateAsync(reviews, reviewParams.pageNumber, reviewParams.pageSize)); }
public Task <PagedList <Review> > GetReviewsForHotel(ReviewParams reviewParams) { var reviews = _context.Reviews .Include(u => u.Sender) .Include(h => h.Recipient) .AsQueryable(); reviews = reviews.Where(h => h.RecipientId == reviewParams.hotelId); return(PagedList <Review> .CreateAsync(reviews, reviewParams.PageNumber, reviewParams.pageSize)); }
public async Task <IActionResult> GetReviewsForUser(Guid userId, ReviewParams reviewParams) { reviewParams.UserId = userId; var reviews = await _repo.GetReviewsForUser(reviewParams); var reviewToReturn = _mapper.Map <IEnumerable <ReviewForListDto> >(reviews); Response.AddPagination(reviews.CurrentPage, reviews.PageSize, reviews.TotalCount, reviews.TotalPages); return(Ok(reviewToReturn)); }
public async Task <IActionResult> GetMoreReviews([FromQuery] ReviewParams reviewParams) { var reviews = await _repo.GetMoreReviews(reviewParams); if (reviews == null) { return(BadRequest()); } var reviewsToReturn = _mapper.Map <IEnumerable <ReviewForListDto> >(reviews); Response.AddPagination(reviews.CurrentPage, reviews.PageSize, reviews.TotalCount, reviews.TotalPages); return(Ok(reviewsToReturn)); }
public async Task <ActionResult <PagedList <UserSeriesReviewListDto> > > GetUserSeriesReviews( string userId, [FromQuery] ReviewParams reviewParams) { var user = await _context.Reviewer.FirstOrDefaultAsync(r => r.ReviewerId == userId); if (user is Reviewer) { var userReviewsQuery = _context.SeriesReview .Where(r => r.ReviewerId == user.ReviewerId) .ProjectTo <UserSeriesReviewListDto>(_mapper.ConfigurationProvider); var pagedReviews = await PagedList <UserSeriesReviewListDto> .CreateAsync(userReviewsQuery, reviewParams.PageNumber, reviewParams.PageSize); return(Ok(pagedReviews)); } return(NotFound()); }
public async Task <IActionResult> DeleteRange(ReviewParams revParams) { int reviewerId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var user = await _repo.GetUser(reviewerId); var isAdmin = await _userManager.IsInRoleAsync(user, "Admin"); if (!isAdmin) { return(Unauthorized()); } var reviews = await _repo.GetReviewsForDelete(revParams); _repo.RemoveMultiple(reviews); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Could not delete Reviews")); }
public async Task <IActionResult> GetReviewsForAdmin(int userId, [FromQuery] ReviewParams reviewParams) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var reviews = await _repo.GetReviewsForAdmin(reviewParams); if (reviews == null) { return(BadRequest()); } var reviewsToReturn = _mapper.Map <IEnumerable <ReviewForAdminListDto> >(reviews); Response.AddPagination(reviews.CurrentPage, reviews.PageSize, reviews.TotalCount, reviews.TotalPages); return(Ok(reviewsToReturn)); }
public async Task <IActionResult> GetReviews(ReviewParams revParams) { var currentUserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); if (revParams.SessionId != 0 && revParams.SessionId != -1) { var session = await _repo.GetSession(revParams.SessionId); if (session != null) { revParams.DateFrom = session.StartDate; revParams.DateTo = session.EndDate; } } if (revParams.ReviewerId == 0) { revParams.ReviewerId = currentUserId; } var reviews = await _repo.GetReviews(revParams); Response.AddPagination(reviews.CurrentPage, reviews.PageSize, reviews.TotalCount, reviews.TotalPages); return(Ok(reviews)); }
public async Task <PagedList <Review> > GetReviewsForAdmin(ReviewParams reviewParams) { var reviews = _context.Reviews.OrderByDescending(d => d.DateAdded); return(await PagedList <Review> .CreateAsync(reviews, reviewParams.PageNumber, reviewParams.PageSize)); }
public void SetData(PartParams tailParams, PartParams bodyParams, PartParams headParams, ReviewParams reviews) { _nameText.text = $"{headParams.Name}{bodyParams.Name}{tailParams.Name}"; _tailImage.sprite = tailParams.FleshImage; _bodyImage.sprite = bodyParams.FleshImage; _headImage.sprite = headParams.FleshImage; _aiText.text = reviews.Lines[Random.Range(0, reviews.Lines.Count)]; }