Пример #1
0
        // leave it empty.
        //public static implicit operator Customer(CorporateCustomer v)
        //{
        //    Customer dbCustomer = new Customer();
        //    dbCustomer = v;
        //    return dbCustomer;
        //}
        public static Customer ConvertModelCustomerIntoEFCustomerToCreate(CorporateCustomer customer)
        {
            Customer efCustomer = new Customer();
            efCustomer.ContactFirstName = customer.ContactFirstName;
            efCustomer.ContactMiddleName = customer.ContactMiddleName;
            efCustomer.ContactLastName = customer.ContactLastName;

            efCustomer.ContactPhone1 = customer.ContactPhone1;
            efCustomer.ContactPhone2 = customer.ContactPhone2;
            efCustomer.ConcactEmail = customer.ConcactEmail;

            efCustomer.CompanyName = customer.CompanyName;
            efCustomer.CompanyPhoneNumber = customer.CompanyPhoneNumber;

            efCustomer.CustomerAddress = customer.CustomerAddress;
            efCustomer.PostCode = customer.PostCode;
            efCustomer.Country = customer.Country;
            efCustomer.City = customer.City;
            efCustomer.IsCorporate = customer.IsCorporate;
            return efCustomer;
        }
Пример #2
0
        public static CorporateCustomer ConvertEFCustomerToModelCustomerToEdit(Customer efcustomer)
        {
            CorporateCustomer customer = new CorporateCustomer();
            customer.CustomerId = efcustomer.CustomerId;
            customer.IsCorporate = efcustomer.IsCorporate;
            customer.ContactFirstName = efcustomer.ContactFirstName;
            customer.ContactMiddleName = efcustomer.ContactMiddleName;
            customer.ContactLastName = efcustomer.ContactLastName;

            customer.ConcactEmail = efcustomer.ConcactEmail;
            customer.ContactPhone1 = efcustomer.ContactPhone1;
            customer.ContactPhone2 = efcustomer.ContactPhone2;

            customer.CompanyName = efcustomer.CompanyName;
            customer.CompanyPhoneNumber = efcustomer.CompanyPhoneNumber;

            customer.CustomerAddress = efcustomer.CustomerAddress;
            customer.City = efcustomer.City;
            customer.Country = efcustomer.Country;

            return customer;
        }
Пример #3
0
        public static CorporateCustomer FormatPhonesForCorporateCustomer(CorporateCustomer myCustomer)
        {
            if (myCustomer.ContactPhone1 != null && myCustomer.ContactPhone1[0] == '+')
            {
                myCustomer.ContactPhone1 = myCustomer.ContactPhone1.Remove(0, 1);
            }

            if (myCustomer.ContactPhone2 != null && myCustomer.ContactPhone2[0] == '+')
            {
                myCustomer.ContactPhone2 = myCustomer.ContactPhone2.Remove(0, 1);
            }

            if (myCustomer.CompanyPhoneNumber != null && myCustomer.CompanyPhoneNumber[0] == '+')
            {
                myCustomer.CompanyPhoneNumber = myCustomer.CompanyPhoneNumber.Remove(0, 1);
            }

            //-----------------------------------------------------------------------------------------------

            if (myCustomer.ContactPhone1 != null)
            {
                myCustomer.ContactPhone1 = string.Concat("+", myCustomer.ContactPhone1);
            }

            if (myCustomer.ContactPhone2 != null)
            {
                myCustomer.ContactPhone2 = string.Concat("+", myCustomer.ContactPhone2);
            }

            if (myCustomer.CompanyPhoneNumber != null)
            {
                myCustomer.CompanyPhoneNumber = string.Concat("+", myCustomer.CompanyPhoneNumber);
            }

            return myCustomer;
        }