public static PendingImportCustomerDTO ToPendingImportCustomerDTO(this UploadedCustomer uploadedCustomer) { var dto = new PendingImportCustomerDTO { CustomerId = uploadedCustomer.CustomerId, ImportAction = UploadedCustomer.ActionType.Skip, FirstName = uploadedCustomer.FirstName, LastName = uploadedCustomer.LastName, Email = uploadedCustomer.EmailAddressText, ExistingCustomerFirstName = uploadedCustomer.ExistingCustomerFirstName, ExistingCustomerLastName = uploadedCustomer.ExistingCustomerLastName, ExistingCustomerEmail = uploadedCustomer.ExistingCustomerEmailAddress, }; var propertiesToHideAddOption = new[] { dto.ExistingCustomerEmail, dto.ExistingCustomerFirstName, dto.ExistingCustomerLastName }; if (propertiesToHideAddOption.Any(p => string.IsNullOrWhiteSpace(p) == false)) { dto.IsMergeAvailable = true; } if (String.Compare(dto.Email, dto.ExistingCustomerEmail, StringComparison.CurrentCultureIgnoreCase) != 0 || !dto.IsMergeAvailable) { dto.IsAddAvailable = true; } return dto; }
public JsonResult ImportCustomers(PendingImportCustomerDTO[] pendingCustomers) { foreach (var pendingCustomer in pendingCustomers) { var matchedCustomers = _importCustomer .UploadedCustomers .Where(c => c.CustomerId == pendingCustomer.CustomerId) .ToList(); matchedCustomers.ForEach(c => c.Action = pendingCustomer.ImportAction); } var importedCustomers = _importCustomer.ImportUploadedCustomers(); var json = Json(importedCustomers); return json; }