Esempio n. 1
0
        public IActionResult CustomerPhoneNumbers(Guid guid)
        {
            Customer customer;

            try
            {
                //customer = PhoneService.FindCustomerByGuid(guid);
                //Moved to controller to enable testing with Moq
                List <Customer> customers = PhoneService.GetAllCustomers();
                customer = customers.FirstOrDefault(c => c.Id == guid);
                if (customer == default(Customer))
                {
                    customer = null;
                }
            }
            catch
            {
                return(NotFound());
            }

            if (customer == null)
            {
                return(NotFound());
            }
            List <PhoneNumber> phoneNumbers = PhoneService.GetAllPhoneNumbers();
            var results = phoneNumbers.Where(p => p.Customer == customer).ToList <PhoneNumber>();

            return(Ok(results));
        }