Example #1
0
        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));
        }
Example #2
0
        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);
        }