// DELETE api/values/5 public void Delete(int hotelId, int reviewId) { var reviews = HotelHelper.GetReviews(hotelId); var review = reviews.FirstOrDefault(r => r.ReviewId == reviewId); if (review != null) { reviews.Remove(review); } }
// PUT api/values/5 public void Put([FromBody] TypeScriptDemo.Domain.HotelReview review) { var reviews = HotelHelper.GetReviews(review.HotelId); var currentReview = reviews.FirstOrDefault(r => r.ReviewId == review.ReviewId); if (currentReview != null) { currentReview.Rating = review.Rating; currentReview.ReviewDate = DateTime.Now; currentReview.ReviewerName = review.ReviewerName; currentReview.Comments = review.Comments; } }
// POST api/values public void Post([FromBody] TypeScriptDemo.Domain.HotelReview review) { var reviews = HotelHelper.GetReviews(review.HotelId); reviews.Add(review); }
// GET api/values // GET api/values/5 public IEnumerable <TypeScriptDemo.Domain.HotelReview> Get(int hotelId) { return(HotelHelper.GetReviews(hotelId)); }