Esempio n. 1
0
 public Customer ConvertFrom(CPlus.Models.Customer customer)
 {
     return(new Customer()
     {
         Name = customer.Name,
         City = customer.City,
         Email = customer.Email,
         Number = customer.Number,
         Phone = customer.Phone,
         State = customer.State,
         Street = customer.Street,
         ZipCode = customer.ZipCode,
     });
 }
Esempio n. 2
0
        public FC.Customer GetOrCreate(CPlus.Models.Customer cPlusCustomer)
        {
            var customers = _client.Execute(new GetCustomersRequest(nameLike: cPlusCustomer.Name));
            var customer  = customers.FirstOrDefault();

            if (customer == null)
            {
                customer = new FC.Customer()
                {
                    Name    = cPlusCustomer.Name,
                    Email   = cPlusCustomer.Email,
                    Phone   = cPlusCustomer.Phone,
                    ZipCode = cPlusCustomer.ZipCode,
                    Street  = cPlusCustomer.Street,
                    Number  = cPlusCustomer.Number,
                    City    = cPlusCustomer.City,
                    State   = cPlusCustomer.State
                };

                var searchAddress = string.Format("{0}, {1} - {2}, {3} - {4}",
                                                  customer.Street,
                                                  customer.Number,
                                                  customer.City,
                                                  customer.State,
                                                  customer.ZipCode
                                                  );
                IEnumerable <Address> addresses = _geoCoder.Geocode(searchAddress);

                if (!addresses.Any())
                {
                    throw new LatitudeLongitudeCouldNotBeDecodedException(searchAddress);
                }

                customer.Latitude  = Convert.ToDecimal(addresses.First().Coordinates.Latitude);
                customer.Longitude = Convert.ToDecimal(addresses.First().Coordinates.Longitude);

                customer = _client.Execute(new CreateCustomerRequest(customer));
            }

            return(customer);
        }
Esempio n. 3
0
 private FC.Customer GetCustomer(CPlus.Models.Customer customer)
 {
     return(_customerFieldControlService.GetOrCreate(customer));
 }