public CustomerResponse GetCustomerContact(CustomerRequest request) { var response = new CustomerResponse(); // Validate request if (request.CustomerContactId > 0) { var customerContactFound = Olympus._Enterprise.CustomerContacts.Where(x => x.Id == request.CustomerContactId).SingleOrDefault(); response.CustomerContact = Mapper.Map<CustomerContactDto>(customerContactFound); } return response; }
public CustomerResponse GetCustomerContacts(CustomerRequest request) { var response = new CustomerResponse(); if (request.CustomerId > 0) { response.CustomerContacts = new List<CustomerContactDto>(); var customerContactList = Olympus._Enterprise.CustomerContacts.Where(x => x.CustomerId == request.CustomerId); response.CustomerContacts = Mapper.Map<List<CustomerContactDto>>(customerContactList); } return response; }
public CustomerResponse SaveCustomer(CustomerRequest request) { var response = new CustomerResponse(); if (request.Customer != null) { // Check if is a new customer if (request.Customer.Id == 0) { // Map the Customer with Contacts Customer customer = Mapper.Map<CustomerDto, Customer>(request.Customer); Olympus._Enterprise.Customers.AddObject(customer); Olympus._Enterprise.SaveChanges(); response.CustomerId = customer.Id; } } return response; }
// 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; }
public CustomerResponse GetCustomer(CustomerRequest request) { var response = new CustomerResponse(); #region *** Intercepted Method *** // Try to bind a customer from Dialcom to Nexus request.CustomerId = SaveCustomer(new CustomerRequest { Customer = _customerAdapter.getCustomer(request).Customer }).CustomerId; #endregion // Validate if the customer is from Nexus if (request.CustomerId > 0) { var customerFound = Olympus._Enterprise.Customers.Where(x => x.Id == request.CustomerId).SingleOrDefault(); Olympus._Enterprise.Detach(customerFound); response.Customer = Mapper.Map<CustomerDto>(customerFound); response.Customer.CustomerContacts = GetCustomerContacts(request).CustomerContacts; } return response; }
private void btnOk_Click(object sender, EventArgs e) { var focusedRow = grdCustomerView.GetFocusedRow() as CustomerDto; if (focusedRow != null) { // Check if the user select a customer if (focusedRow.Id > -1) { var request = new CustomerRequest(); request.CustomerId = focusedRow.Id; // Needed for Interceptor request.Customer = new CustomerDto() { Name = focusedRow.Name}; Tag = new CustomerFactory().GetCustomer(request).Customer; DialogResult = System.Windows.Forms.DialogResult.OK; } else { // Check if is a new customer } } }
// 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; } } } }
private void SearchCustomer(string query) { var request = new CustomerRequest(); request.SearchCustomerQuery = query; ShowSearchResults(new CustomerFactory().SearchCustomer(request).CustomerList); }
public CustomerResponse SearchCustomer(CustomerRequest request) { return _customerService.SearchCustomer(request); }
public CustomerResponse SaveCustomerContact(CustomerRequest request) { return _customerService.SaveCustomerContact(request); }
public CustomerResponse GetCustomer(CustomerRequest request) { return _customerService.GetCustomer(request); }
private void saveContact() { var request = new CustomerRequest(); request.CustomerContact = captureContact(); var response = new CustomerFactory().SaveCustomerContact(request); if (response.CustomerContactId > 0) { Tag = new CustomerFactory().GetCustomerContact(new CustomerRequest { CustomerContactId = response.CustomerContactId }).CustomerContact; } }
// 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; }
public CustomerResponse SaveCustomerContact(CustomerRequest request) { var response = new CustomerResponse(); // Validate contact has a customer related if (request.CustomerContactId > 0) { CustomerContact contact; // Check if Edit or Add if (request.CustomerContact.Id > 0) { // Edit contact = Olympus._Enterprise.CustomerContacts.Where(x => x.Id == request.CustomerContact.Id).SingleOrDefault(); Mapper.Map(request.CustomerContact, contact); }else{ // Add contact = Mapper.Map<CustomerContact>(request.CustomerContact); Olympus._Enterprise.CustomerContacts.AddObject(contact); } Olympus._Enterprise.SaveChanges(); if (contact != null) response.CustomerContactId = contact.Id; } return response; }
private void saveCustomer() { var request = new CustomerRequest(); request.Customer = captureCustomer(); request.CustomerId = new CustomerFactory().SaveCustomer(request).CustomerId; // Put the new customer on Tag Tag = new CustomerFactory().GetCustomer(request).Customer; this.DialogResult = System.Windows.Forms.DialogResult.OK; }