public List <CustomerAndPhoneNumberInformation> GetCustomersByPhone(string phone)
        {
            List <CustomerAndPhoneNumberInformation> customersToReturn = new List <CustomerAndPhoneNumberInformation>();
            List <PhoneNumber> listPhones = Context.PhoneNumbers.Where(c => c.Phone.Contains(phone)).ToList();
            List <Customer>    customers  = new List <Customer>();

            foreach (var listPhone in listPhones)
            {
                var customer = Context.Customers.Where(c => c.Id == listPhone.IdCustomer).FirstOrDefault();
                if (!customers.Contains(customer))
                {
                    customers.Add(customer);
                }
            }
            foreach (var customer in customers)
            {
                if (customer.IsActive)
                {
                    var newCustomer = new CustomerAndPhoneNumberInformation();
                    newCustomer.Customer            = customer;
                    newCustomer.PhoneNumberAndTypes = GetPhoneNumberAndTypes(customer.Id);
                    customersToReturn.Add(newCustomer);
                }
            }
            return(customersToReturn.OrderBy(c => c.Customer.LastName + c.Customer.FirstName).ToList());
        }
        public List <CustomerAndPhoneNumberInformation> GetCustomersByName(string name)
        {
            List <CustomerAndPhoneNumberInformation> customersToReturn = new List <CustomerAndPhoneNumberInformation>();
            List <Customer> customers = Context.Customers.Where(c => c.LastName.Contains(name) ||
                                                                c.FirstName.Contains(name) || (c.FirstName + " " + c.LastName).Contains(name)).ToList();

            foreach (var customer in customers)
            {
                if (customer.IsActive)
                {
                    var newCustomer = new CustomerAndPhoneNumberInformation();
                    newCustomer.Customer            = customer;
                    newCustomer.PhoneNumberAndTypes = GetPhoneNumberAndTypes(customer.Id);
                    customersToReturn.Add(newCustomer);
                }
            }
            return(customersToReturn.OrderBy(c => c.Customer.LastName + c.Customer.FirstName).ToList());
        }
        internal ActionResult <List <CustomerAndPhoneNumberInformation> > GetCustomersWithPhone()
        {
            List <CustomerAndPhoneNumberInformation> customers = new List <CustomerAndPhoneNumberInformation>();

            foreach (var customer in Context.Customers)
            {
                if (customer.IsActive)
                {
                    var newCustomer = new CustomerAndPhoneNumberInformation
                    {
                        Customer            = customer,
                        PhoneNumberAndTypes = GetPhoneNumberAndTypes(customer.Id)
                    };
                    customers.Add(newCustomer);
                }
            }
            return(customers.OrderBy(c => c.Customer.LastName + c.Customer.FirstName).ToList());
        }