Esempio n. 1
0
        public async Task <HttpResponseMessage> AddReview(string email, string MovieID, string MovieTitle, string MovieYear, string Reviews)
        {
            try
            {
                List <string> request_response = new List <string> {
                };

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

                //To check if the provided user email is present in DB
                RegistrationRepository regrep = new RegistrationRepository();
                var checkuser = await regrep.CheckUserExistance(email);


                //If the user is not present in DB
                if (checkuser.Count() == 0)
                {
                    response.responsecode = false;
                    response.responsemessage.Add("Cannot add Review as the provided email doesnot exist");
                    //string requestJSON = JsonConvert.SerializeObject(request, Formatting.Indented);

                    //request_response.Add("false");
                    //request_response.Add("Cannot add Review as the provided email doesnot exist");
                    //return Request.CreateResponse(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"));
                    return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json")));
                }

                //If user is present in DB
                else
                {
                    var review = await reviewRepository.AddReview(email, MovieID, MovieTitle, MovieYear, Reviews);

                    response.responsecode = review;
                    response.responsemessage.Add("Review added Successfully");
                    return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json")));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message, MediaTypeHeaderValue.Parse("application/json")));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> AddReview(string ReviewId, ReviewDTO reviewDTO)
        {
            try
            {
                var     userID = "B7C60175-B370-4CE4-AC86-08D81D38F5FE";
                dynamic result = await _review.AddReview(reviewDTO, userID);

                if (result.Success == false)
                {
                    return(BadRequest(result));
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }
Esempio n. 3
0
        public async Task <ActionResult> Create(Review review)
        {
            await _context.AddReview(review);

            return(CreatedAtRoute("GetReview", new { id = review.PetID }, review));
        }
Esempio n. 4
0
 public IActionResult AddReview(Review review)
 {
     repository.AddReview(review);
     return(RedirectToAction(nameof(Index)));
 }