public IActionResult Post([FromBody] Rating rating) { //This is the beginning of the conditional logic block if (rating == null) { return(BadRequest()); } else if (rating.Id == 0) { _ratingService.AddRating(rating); return(Ok()); } else { _ratingService.UpdateRating(rating); return(Ok()); } //This is the end of the conditional logic block }
public ActionResult <Rating> PostRating([FromBody] Rating rating) { rating.UserId = GetUserId(); _ratingsService.AddRating(rating); return(CreatedAtAction("GetRating", new { id = rating.Id }, rating)); }