public void LoadData()
        {
            _Customers = new ObservableCollection<CustomerModel>();

            var customerList = customerRepository.Retrieve();

            CustomerTypeRepository customerTypeRepository = new CustomerTypeRepository();
            var customerTypeList = customerTypeRepository.Retrieve();

            //var sortedList = customerRepository.SortByName(customerList);
           // var itemList = customerRepository.GetNamesAndId(customerList);

            //var itemList = customerRepository.GetNamesAndType(customerList,
            //                                        customerTypeList);


            var query = customerList.Join(customerTypeList,
                                c => c.CustomerTypeId,
                                ct => ct.CustomerTypeId,
                                (c, ct) => new CustomerModel
                                {
                                    Name = c.LastName + ", " + c.FirstName,
                                    CustomerTypeName = ct.TypeName
                                });

            foreach (var customerInstance in query.OrderBy(c=>c.Name))
            {
                _Customers.Add(customerInstance);
            }
        }
Exemplo n.º 2
0
        private void GetCustomersButton_Click(object sender, EventArgs e)
        {
            //CustomerGridView.DataSource = customerRepository.Retrieve();

            var customerList = customerRepository.Retrieve();
            //CustomerGridView.DataSource = customerRepository.SortByName(customerList).ToList();

            //CustomerGridView.DataSource = customerRepository.GetOverdueCustomers(customerList).ToList();

            //var unpaidCustomerList = customerRepository.GetOverdueCustomers(customerList);
            //CustomerGridView.DataSource = customerRepository.SortByName(unpaidCustomerList).ToList();

            CustomerTypeRepository customerTypeRepository = new CustomerTypeRepository();
            var customerTypeList = customerTypeRepository.Retrieve();

            CustomerGridView.DataSource = customerRepository.GetNamesAndType(customerList,
                                                customerTypeList);
        }