Example #1
0
        public HttpResponseMessage selectReview([FromBody] SelectReviewOperator body)
        {
            ReviewPersistenceService ReviewPersistenceService = new ReviewPersistenceService();
            HttpResponseMessage      response;

            if ((body.op != ">") && (body.op != "<") && (body.op != "="))
            {
                response = Request.CreateResponse(HttpStatusCode.BadRequest,
                                                  "op field of body must be one of `>`, `<`, or `=`. Please try again.");
                return(response);
            }

            else
            {
                var Reviews = ReviewPersistenceService.GetSelectReviews(body.op, body.rating);
                if (Reviews == null || Reviews.Count.Equals(0))
                {
                    response = Request.CreateResponse(HttpStatusCode.NotFound, "No Reviews found.");
                    return(response);
                }
                response = Request.CreateResponse(HttpStatusCode.OK, Reviews);
                return(response);
            }
        }