PRTools.Web.Models.CustomerManagementViewModel.AddCustomer C# (CSharp) Method

AddCustomer() public method

public AddCustomer ( CustomerViewModel customerViewModel ) : void
customerViewModel CustomerViewModel
return void
        public void AddCustomer(CustomerViewModel customerViewModel)
        {
            _customers.Add(customerViewModel);
        }

Usage Example

        private CustomerManagementViewModel getCustomers(bool onlyShowParents = false, string SearchCriteria = "")
        {
            IEnumerable<Customer> customers = QuickSearchCustomers(User.Identity.Name,
                                                                   new QuickSearchCustomersRequest
                                                                       {SearchString = SearchCriteria});
            if (onlyShowParents)
            {
                customers = customers.Where(c => c.ParentCustomerId == 0);
            }
            var customerManagementViewModel = new CustomerManagementViewModel();
            foreach (
                Customer customer in
                    customers.OrderBy(c => c.ParentName).ThenBy(c => c.ParentCustomerId).ThenBy(c => c.Name))
            {
                CustomerViewModel customerViewModel = Mapper.Map<Customer, CustomerViewModel>(customer);

                if (customer.Contacts.Count() > 0)
                {
                    customerViewModel.ContactFirstName = customer.Contacts.First().FirstName;
                    customerViewModel.ContactLastName = customer.Contacts.First().LastName;
                    customerViewModel.ContactPhone = customer.Contacts.First().Phone;
                }

                customerManagementViewModel.AddCustomer(customerViewModel);
            }
            return customerManagementViewModel;
        }
All Usage Examples Of PRTools.Web.Models.CustomerManagementViewModel::AddCustomer