示例#1
0
        private CustomerDto captureCustomer()
        {
            // If tag is null this means that the customer is new
            CustomerDto customer;
            if (Tag == null)
            {
                customer = new CustomerDto();
            }else{
                // Get the instance from Tag to Edit
                customer = Tag as CustomerDto;
            }
            customer.Name = txtCustomerName.Text;
            customer.Address = txtCustomerAddress.Text;
            customer.AddressOptional = txtCustomerAddressOptional.Text;
            customer.Phone = txtCustomerPhone.Text;
            customer.Fax = txtCustomerFax.Text;

            // Get the CustomerContacts
            customer.CustomerContacts = new List<CustomerContactDto>();
            foreach (CustomerContactDto contact in cmbContacts.Properties.Items)
            {
                customer.CustomerContacts.Add(contact);
            }
            return customer;
        }
示例#2
0
 internal static CustomerDto Map(Nexus.Customer customer)
 {
     CustomerDto tmpCustomerData = null;
     if (customer != null)
     {
         tmpCustomerData = new CustomerDto();
         tmpCustomerData.Id = customer.Id;
         tmpCustomerData.Name = customer.Name;
         tmpCustomerData.Address = customer.Address;
     }
     return tmpCustomerData;
 }
示例#3
0
        private void FixupCustomer(CustomerDto previousValue)
        {
            if (previousValue != null && ReferenceEquals(previousValue.BindCustomer, this))
            {
                previousValue.BindCustomer = null;
            }

            if (Customer != null)
            {
                Customer.BindCustomer = this;
                if (CustomerId != Customer.Id)
                {
                    CustomerId = Customer.Id;
                }
            }
        }
示例#4
0
        // Get Customer
        public CustomerResponse getCustomer(CustomerRequest request)
        {
            CustomerResponse response = new CustomerResponse();
            // Check if customers needs a binding
            if (request.CustomerId == 0 && request.Customer.Name != "")
            {
                // Apply the search the customer
                var customerFound = Asgard._Foreing.CLI_CLIENTES.Where(x => x.CLI_Nombre.ToUpper() == request.Customer.Name.ToUpper()).FirstOrDefault();

                if (customerFound != null)
                {
                    // Add the Customer to Nexus
                    var newCustomer = new CustomerDto()
                    {
                        Name = customerFound.CLI_Nombre,
                        Address = customerFound.CLI_Direccion
                    };

                    newCustomer.BindCustomer = new BindCustomerDto { AlienId = customerFound.CLI_Cliente };

                    // Check if the Customer has a contact defined
                    if (customerFound.CLI_Contacto != null)
                    {
                        // Add Person to Contact
                        var newPerson = new PersonDto()
                        {
                            Name = customerFound.CLI_Contacto,
                            LastName = ""
                        };
                        // Add Contact to Customer
                        var newCustomerContact = new CustomerContactDto()
                        {
                            Job = "Funcionario",
                            Person = newPerson,
                            Email = "*****@*****.**"
                        };
                        newCustomer.CustomerContacts.Add(newCustomerContact);
                    }
                    response.Customer = newCustomer;
                }
            }
            return response;
        }
示例#5
0
        // Add aditional customers to the search
        public void searchCustomer(CustomerRequest request, CustomerResponse response)
        {
            const int maximunResultRows = 10;

            // Get customers from respective employee NEEDS IMPLEMENTATION
            // var tmpEmployee = Asgard._Foreing.CLI_CLIENTES.Where(x => x.Id == SessionManager.EmployeeId).SingleOrDefault();

            // Apply the search with the pattern given
            var customersFound = Asgard._Foreing.CLI_CLIENTES.Where(x => x.CLI_Nombre.ToUpper().Contains(request.SearchCustomerQuery.ToUpper()) & x.CLI_Activo == 1).OrderBy(y => y.CLI_Nombre).Take(maximunResultRows).ToList();

            // Add customers to the list
            if (customersFound != null)
            {
                // Fill the response with the customers found
                foreach (var customer in customersFound)
                {
                    // Check if the customer is already binded
                    var bindedCustomer = response.CustomerList.Where(x => x.BindCustomer.AlienId == customer.CLI_Cliente).FirstOrDefault();
                    if(bindedCustomer == null)
                    {
                        // Add customer to list
                        var tmpCustomerData = new CustomerDto();
                        tmpCustomerData.Name = customer.CLI_Nombre.Trim();
                        tmpCustomerData.Address = customer.CLI_Direccion;
                        response.CustomerList.Add(tmpCustomerData);
                    }
                    else
                    {
                        // Update customer in list
                        bindedCustomer.Name = customer.CLI_Nombre.Trim();
                        bindedCustomer.Address = customer.CLI_Direccion;
                    }

                }
            }
        }
示例#6
0
 // Load the Customer
 private void loadCustomer(CustomerDto customer)
 {
     cmbCustomerName.Text = "";
     lblAddress.Text = "";
     loadContactList(null);
     if (customer != null)
     {
         cmbCustomerName.Tag = customer;
         cmbCustomerName.Text = customer.Name;
         lblAddress.Text = customer.Address;
         loadContactList(customer.CustomerContacts);
     }
 }
示例#7
0
        private void FixupCustomer(CustomerDto previousValue)
        {
            if (previousValue != null && previousValue.Projects.Contains(this))
            {
                previousValue.Projects.Remove(this);
            }

            if (Customer != null)
            {
                if (!Customer.Projects.Contains(this))
                {
                    Customer.Projects.Add(this);
                }
                if (CustumerId != Customer.Id)
                {
                    CustumerId = Customer.Id;
                }
            }
        }
示例#8
0
        // Search Customers
        public CustomerResponse SearchCustomer(CustomerRequest request)
        {
            var response = new CustomerResponse {CustomerList = new List<CustomerDto>()};

            // *** Removed functionality ***
            // Get customers from respective employee
            // var tmpEmployee = Olympus._Enterprise.Employees.Where(x => x.Id == SessionManager.EmployeeId).SingleOrDefault();
            // Apply the search with the pattern given
            //var customersFounded = tmpEmployee.Customers.Where(x => x.Name.ToUpperInvariant().Contains(request.SearchCustomerQuery.ToUpperInvariant())).OrderBy(y => y.Name).Take(maximunResultRows).ToList();

            // Search customers without employee restriction
            var customersFound = Olympus._Enterprise.Customers.Where(x => x.Name.Contains(request.SearchCustomerQuery)).OrderBy(y => y.Name).Take(Convert.ToInt32(Properties.Resources.MaximunResultRows)).Distinct().ToList();

            if (customersFound.Count > 0 )
            {
                // Fill the response with the customers founded
                foreach (var customer in customersFound)
                {
                    var tmpCustomerData = new CustomerDto
                                                      {
                                                          Id = customer.Id,
                                                          Name = customer.Name,
                                                          Address = customer.Address
                                                      };
                    response.CustomerList.Add(tmpCustomerData);
                }
            }

            // Intercepted Method
            _customerAdapter.searchCustomer(request, response);

            // Sorted again the list
            response.CustomerList = response.CustomerList.OrderBy(x => x.Name).ToList();

            return response;
        }