public ActionResult CreateReview(HomeModel model) { var review = new ReviewDomain() { UserName = model.UserName, LikeMessage = model.LikeMessage, DislikeMessage = model.DislikeMessage, Comment = model.Comment, CreateDate = DateTime.Now, IsDeleted = false, Rate = Int32.Parse(model.Rate), Address = model.Address, OrganizationName = model.Organization }; try { _reviewService.AddReview(review); return(Json(new { redirectUrl = Url.Action("Index", "Review") })); } catch (Exception ex) { throw; } }
public async Task <IActionResult> Review(Review review) { review.UserId = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); var createdReview = await _reviewService.AddReview(review); return(LocalRedirect("/")); }
public void AddReview(string bookReview, int bookId) { var review = new Review(); review.Comment = bookReview; review.BookId = bookId; reviewService.AddReview(review); }
public ActionResult AddReview(ReviewDTO review) { if (ModelState.IsValid) { review.Date = DateTime.Now; reviewService.AddReview(review); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Add(Review model) { if (ModelState.IsValid) { await _service.AddReview(model); return(RedirectToActionPermanent("Index")); } return(View(model)); }
public IActionResult Add(int id, string comment) { if (ModelState.IsValid) { var userId = this.userManager.GetUserId(User); reviewService.AddReview(userId, id, comment); } return(NoContent()); //return RedirectToAction(nameof(GetMovieReviews), new { id = id }); //return RedirectToAction("Details", "Movies", new { id = id }); }
public IActionResult OnPost() { Review.User = new User(); string testname; HttpContext.Request.Cookies.TryGetValue("UserName", out testname); Review.User.Username = testname; Review.Album = new Album(); Review.Album.AlbumID = albumid; Review.StarRating = StarRating; //Review.PublishDateTime = DateTime.Now; _reviewService.AddReview(Review); return(RedirectToPage("HomePage")); }
public IActionResult AddReview(int userID, int bookID, [FromBody] ReviewViewModel review) { if (!ModelState.IsValid) { var error = new ErrorDTO { Code = 412, Message = "Validation error. Invalid input" }; return(StatusCode(error.Code, error)); } try { var addedReview = reviewService.AddReview(userID, bookID, review); return(CreatedAtRoute("GetUserReview", new { userID = userID, bookID = bookID }, addedReview)); } catch (NotFoundException ex) { var error = new ErrorDTO { Code = 404, Message = ex.Message }; return(StatusCode(error.Code, error)); } catch (AlreadyExistsException ex) { var error = new ErrorDTO { Code = 409, Message = ex.Message }; return(StatusCode(error.Code, error)); } catch (Exception ex) { var error = new ErrorDTO { Code = 500, Message = ex.Message }; return(StatusCode(error.Code, error)); } }
public IHttpActionResult AddReview(ReviewToAddDto reviewDto) { if (!ModelState.IsValid) { return(StatusCode(HttpStatusCode.BadRequest)); } var review = Mapper.Map <Review>(reviewDto); _reviewService.AddReview(review); _reviewService.Complete(); return(Ok()); }
public async Task <IActionResult> OnPostAsync(int id) { if (!ModelState.IsValid) { return(Page()); } if (id == 0) { await _reviewService.AddReview(Review); } else { await _reviewService.UpdateReview(Review); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> AddReview(ReviewModel reviewModel) { if (!ModelState.IsValid) { return(BadRequest()); } var user = User; var result = await _reviewService.AddReview(reviewModel, user); if (result.Error != null) { return(BadRequest(result)); } return(Ok(result)); }
public IActionResult Create(int movieId, [FromBody] ReviewInputModel inputModel) { if (inputModel == null) { return(BadRequest()); } if (!_movieService.MovieExists(movieId)) { return(NotFound()); } var model = ToDomainModel(inputModel); _reviewService.AddReview(model); var outputModel = ToOutputModel(model); return(CreatedAtRoute("GetReview", new { movieId = outputModel.MovieId, id = outputModel.Id }, outputModel)); }
public ActionResult Create(string reviewText, string reviewRating, int placeId) { try { var reviewViewModel = new ReviewViewModels() { Text = reviewText.Length > 0 ? reviewText : null, Rating = int.Parse(reviewRating), UserId = _userManager.GetUserId(User), PlaceId = placeId }; var reviewModel = _reviewService.AddReview(reviewViewModel); return(Json(reviewModel)); } catch { return(View()); } }
public async Task <IActionResult> AddReview([FromBody] Review review) { _logger.LogInformation("Adding new review"); try { await _reviewService.AddReview(review); _logger.LogInformation("Review added to database Successfully"); await _bus.Publish(new UpdateRestaurantEvent(review.RestaurantId, null, null, review.Rating, null, null, 0.0M)); _logger.LogInformation("Restaurant event Successfully"); return(CreatedAtRoute("Get", review)); } catch (Exception ex) { _logger.LogError("An error occured while adding new review", ex.Message); return(Ok(HttpStatusCode.InternalServerError)); } }
public IActionResult Create(int bookId, [FromBody] Review review) { if (review == null) { return(BadRequest()); } if (!bookService.BookExsists(bookId)) { return(NotFound()); } reviewService.AddReview(review); var outputModel = ToOutputModel(review); return(CreatedAtRoute("GetReview", new { bookId = outputModel.BookId, id = outputModel.Id }, outputModel)); }
public ActionResult Create([Bind(Include = "ReviewerName,Rating, restaurantId")] ReviewViewModel reviewerInfo) { if (ModelState.IsValid) { try { int newId = _reviewService.GetAllReviewerInfo().Select(x => x.reviewerId).Max() + 1; reviewerInfo.reviewerId = newId; reviewerInfo.Date = DateTime.Now; var res = reviewerInfo.restaurantId; var review = _mapper.Map <ReviewerInfo>(reviewerInfo); _reviewService.AddReview(review); _loggingService.Log("Created a new review with id: " + reviewerInfo.restaurantId); return(RedirectToAction("AllReviews", new { id = reviewerInfo.restaurantId })); } catch (Exception e) { _loggingService.Log(e); } } _loggingService.Log("Review model created was not valid"); return(RedirectToAction("AllReviews", reviewerInfo.restaurantId)); }
public IActionResult AddReview([FromBody] ReviewViewModel review, int user_id, int book_id) { if (review == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(StatusCode(412)); } review.UserId = user_id; review.BookId = book_id; review.DateWritten = DateTime.Now; try { _reviewService.AddReview(review, user_id, book_id); } catch (NotFoundException e) { return(NotFound()); } return(StatusCode(201)); }
public void TestAddReview() { reviewService.AddReview(request); }
public async Task <IActionResult> Post([FromBody] CreatedReviewModel model) { await _reviewService.AddReview(UserId, _mapper.Map <CreatedReview>(model)); return(Success()); }
public async Task <IActionResult> AddArticle(ReviewDto reviewDto) { var result = await _reviewService.AddReview(reviewDto); return(Ok(result)); }
public IActionResult AddReview(Review review) { _reviewService.AddReview(review); return(View()); }
public async Task <IActionResult> Add([FromBody] Reviews review) { return(Ok(await _reviewService.AddReview(review))); }