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 async Task <IActionResult> GetRates([FromRoute] RatesRequest request) { var rates = await ratesService.GetRates(request.From, request.To); return(this.Ok(new RatesResponse() { From = request.From, Rates = rates.ToArray() })); }
public async Task <IActionResult> GetRates([FromBody] InputExchangeDataModel data) { var result = await _ratesService.GetRates(data); return(Ok(result));//TODO: response handling in BaseController }
public async Task <IActionResult> GetRates([FromBody] InputExchangeDataModel data) { var result = await _ratesService.GetRates(data); return(Ok(result)); }