示例#1
0
        public async Task <HttpResponseMessage> RemoveReview(string email, string MovieID, string MovieTitle, string MovieYear, string Reviews)
        {
            List <string> request_response = new List <string> {
            };

            try
            {
                //To check if the provided favourite is present in DB
                var checkReview = await reviewRepository.GetReview(email, MovieID, MovieTitle, MovieYear, Reviews);

                //Response Creator
                Response response = new Response();

                //If the user is not present in DB
                if (checkReview.Count() == 0)
                {
                    //request_response.Add("false");
                    //request_response.Add("Provided Review doesnot exist");
                    //return Request.CreateResponse(HttpStatusCode.OK, request_response, MediaTypeHeaderValue.Parse("application/json"));
                    response.responsecode = false;
                    response.responsemessage.Add("Provided Review doesnot exist");
                    return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json")));
                }

                //If user is present in DB
                else
                {
                    #region Success resopnse


                    var response2 = await reviewRepository.RemoveReview(email, MovieID, MovieTitle, MovieYear, Reviews);

                    //request_response.Add(response2.ToString());
                    //request_response.Add("Review removed Successfully");
                    //return Request.CreateResponse(HttpStatusCode.OK, request_response, MediaTypeHeaderValue.Parse("application/json"));
                    response.responsecode = response2;
                    response.responsemessage.Add("Review removed Successfully");
                    return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json")));



                    #endregion
                }
            }
            catch (Exception ex)
            {
                //request_response.Add("False");
                //
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message, MediaTypeHeaderValue.Parse("application/json")));
            }
        }
示例#2
0
        public IActionResult getReview(int reviewId)
        {
            if (!_reviewRepository.ReviewExist(reviewId))
            {
                return(NotFound());
            }
            var reviews = _reviewRepository.GetReview(reviewId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            return(Ok(reviews));
        }