public void UpdateReview(Guid bookId, Guid reviewId, UpdateReviewModel model) { var child = BookFromAuthor(bookId).Reviews.Single(review => review.Id == reviewId); child.Comment = model.Comment; child.Rating = model.Rating; child.ReviewerName = model.ReviewerName; }
private async Task <IActionResult> UpdateIn(string objCode, UpdateReviewModel model) { if (!await HasObject(objCode, model.PlaceId)) { return(BadRequest("No such place")); } if (model.Id <= 0) { return(BadRequest("invalid model")); } var exists = await Service.Get(model.Id); if (this.GetUserRole() == "admin") { if (this.GetUserId() != exists.UserId) { var res = await Service.Update(model.Id, model.Text != null, model.Text, null, model.IsVisible); return(Ok(res)); } else { var res = await Service.Update(model.Id, model.Text != null, model.Text, model.Rate, model.IsVisible); if (model.Rate != null) { await RecalculateRating(objCode, model.PlaceId); } return(Ok(res)); } } else { if (this.GetUserId() != exists.UserId) { return(BadRequest()); } var res = await Service.Update(model.Id, model.Text != null, model.Text, model.Rate, null); if (model.Rate != null) { await RecalculateRating(objCode, model.PlaceId); } return(Ok(res)); } }
public Task <IActionResult> UpdateToEvent([FromBody] UpdateReviewModel model) => UpdateIn(PlaceTypesConfig.EventCode, model);
public Task <IActionResult> UpdateToRoute([FromBody] UpdateReviewModel model) => UpdateIn(PlaceTypesConfig.RouteCode, model);
public Task <IActionResult> UpdateToAttraction([FromBody] UpdateReviewModel model) => UpdateIn(PlaceTypesConfig.AttractionCode, model);
public Task <IActionResult> UpdateToHotel([FromBody] UpdateReviewModel model) => UpdateIn(PlaceTypesConfig.HotelCode, model);
public IActionResult Update(Guid bookId, Guid reviewId, [FromBody] UpdateReviewModel model) { ReviewService.UpdateReview(bookId, reviewId, model); return(Ok()); }