public async Task <IActionResult> CalcPrice([FromBody] NamePhones phones) { double price = await _calculate.CalculatePrice(phones); if (price == -1) { return(NotFound("Data not found")); } return(Ok(price)); }
public async Task <double> CalculatePrice(NamePhones phones) { Phone phoneOnePrice = await _repository.GetPhone(phones.NameOnePhone); Phone phoneSecondPrice = await _repository.GetPhone(phones.NameSecondPhone); if (phoneOnePrice == null || phoneSecondPrice == null) { return(-1); } return(phoneOnePrice.Price - phoneSecondPrice.Price); }