public IHttpActionResult Get([FromUri] RatingSearchParams spaceID) { var response = _service.GetAllRatings(spaceID); if (response == null) { return(NotFound()); } return(Ok(response)); }
public IEnumerable <RatingListItem> GetAllRatings(RatingSearchParams model) { using (var ctx = new ApplicationDbContext()) { return(ctx.Ratings .Where(r => r.SpaceId == model.SpaceId) .Select(r => new RatingListItem { SpaceId = r.SpaceId, Comments = r.Comments, CleanlinessRating = r.CleanlinessRating, EnvironmentRating = r.EnvironmentRating, ResponsivenessRating = r.ResponsivenessRating, LuxuryRating = r.LuxuryRating, AccessibilityRating = r.AccessibilityRating, RatingId = r.Id } ).ToList()); } }