public ActionResult <CustomerDto> Get([FromBody] CustomerInquiryDto customerIquiry)
        {
            if (string.IsNullOrEmpty(customerIquiry.Email) && customerIquiry.CustomerID == 0)
            {
                return(BadRequest(new { message = "Invalid criteria" }));
            }

            var result = _customerService.GetCustomer(customerIquiry);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Ejemplo n.º 2
0
        public CustomerDto GetCustomer(CustomerInquiryDto inquiryDto)
        {
            CustomerDto result;

            if (!string.IsNullOrEmpty(inquiryDto.Email))
            {
                result = GetCustomer(inquiryDto.Email);
                if (inquiryDto.CustomerID != 0 && result.CustomerId != inquiryDto.CustomerID)
                {
                    throw new ValidationException("email and customer ID are not consistent");
                }
                return(result);
            }

            return(GetCustomer(inquiryDto.CustomerID));
        }