/// <summary> /// Method to cancel the rate by id /// </summary> /// <returns> /// Returns bad request in case of token not given as header or if the instance was not rated by the user with given token /// Returns the modified entity in case the rate was cancelled successfully /// </returns> public IHttpActionResult DeleteUserRating(int newsInstanceId) { IEnumerable <string> values; if (!Request.Headers.TryGetValues("Token", out values)) { return(BadRequest("Token was not given. Use a token that was used to rate this instance")); } string token = values.FirstOrDefault(); var userRating = RatingManager.CheckRateLogged(db, token, newsInstanceId); if (userRating == null) { return(BadRequest("User with given token has not rated the news with given id")); } return(Ok((NewsInstanceViewModel)RatingManager.CancelRate(db, userRating))); }