private void AddRate(RecipeDto recipe) { var rates = _ratesService.GetRates(recipe.Id); if (_loggedUser != null) { var loggedUserRate = rates.SingleOrDefault(x => x.User.Id == _loggedUser.Id); if (loggedUserRate != null) { Console.WriteLine($"Your rate: {loggedUserRate.Score}"); } else { var choice = _getDataFromUser.GetData("Do you want to rate this recipe? Y/N"); if (choice.ToUpper() == "Y") { var score = _getDataFromUser.GetNumber("Your rate (0-10): ", 0, 10); var rate = new RateDto { Id = Guid.NewGuid(), Score = score, User = _loggedUser, Recipe = recipe }; var result = _ratesService.AddRate(rate); ShowResult(result); UpdateLoggedUser(); } ; } } }
public RateDto AddRate([FromBody] RateDto rate) { return(_ratesService.AddRate(rate)); }