public string AddReview(WrittenReview review) { review.Content = review.Content.Replace("\n\n\n", "\n"); review.Rating = 5; if(review.Title.Length > 30) { review.Title.Substring(0, 30); } if (review.Content.Length > 7000) { review.Content.Substring(0, 7000); } this._repo.Add(review); this._repo.SaveChanges(); return "Your Review has been submitted"; }
public IHttpActionResult PostNewReview(WrittenReview review) { review.Title = Regex.Replace(review.Title, @"<[^>]*>", String.Empty); review.Content = Regex.Replace(review.Content, @"<[^>]*>", String.Empty); if (review.Content == null || review.Content == "") { ModelState.AddModelError("Content", "Review content is empty"); } if(review.Title == null || review.Title == "") { ModelState.AddModelError("Title", "Review title is empty"); } if (!ModelState.IsValid) { return BadRequest(ModelState); } this._reviewService.AddReview(review); return Created("/reviews/" + review.Id, review); }