Beispiel #1
0
 public Customer(UserName newName, Address newAddress, ContactInformation contactInformation, Customer.AccountType newType)
 {
     Address            = newAddress;
     Name               = newName;
     Type               = newType;
     ContactInformation = contactInformation;
 }
Beispiel #2
0
        private Customer CreateCustomer()
        {
            String postal = CheckBlankBoxes(PostalBox);
            String email  = CheckBlankBoxes(EmailBox);
            String phone  = CheckBlankBoxes(PhoneBox);

            Customer.AccountType type      = GetAccountType();
            UserName             user      = new UserName(FirstNameBox.Text, LastNameBox.Text);
            Address            userAddress = new Address(SuiteBox.Text, StreetBox.Text, HouseBox.Text, CityBox.Text, ProvinceBox.Text, postal);
            ContactInformation userInfo    = new ContactInformation(email, phone);
            Credentials        credentials = new Credentials(UsernameTextBox.Text, PasswordTextBox.Text);
            Customer           newCustomer = new Customer(user, userAddress, userInfo, type);

            newCustomer.Credentials = credentials;

            return(newCustomer);
        }
Beispiel #3
0
        private static Customer CreateCustomerFromRow(DataRow row)
        {
            string firstName;

            if (row.IsNull("first_name"))
            {
                return(null);
            }
            firstName = row["first_name"].ToString();

            string lastName;

            if (row.IsNull("last_name"))
            {
                return(null);
            }
            lastName = row["last_name"].ToString();

            string suite = "";

            if (!row.IsNull("suite_number"))
            {
                suite = row["suite_number"].ToString();
            }

            string street = "";

            if (!row.IsNull("street_number"))
            {
                street = row["street_number"].ToString();
            }

            string house = "";

            if (!row.IsNull("house_number"))
            {
                house = row["house_number"].ToString();
            }

            string city = "";

            if (!row.IsNull("city"))
            {
                city = row["city"].ToString();
            }

            string province = "";

            if (!row.IsNull("province"))
            {
                province = row["province"].ToString();
            }

            string postalCode = "";

            if (!row.IsNull("postalcode"))
            {
                postalCode = row["postalcode"].ToString();
            }

            string email = "";

            if (!row.IsNull("email"))
            {
                email = row["email"].ToString();
            }

            string phone = "";

            if (!row.IsNull("phone_number"))
            {
                phone = row["phone_number"].ToString();
            }

            DateTime creationDate;

            if (row.IsNull("creation_date"))
            {
                return(null);
            }
            creationDate = (DateTime)row["creation_date"];

            string creditCard = "";

            if (!row.IsNull("credit_card"))
            {
                creditCard = row["credit_card"].ToString();
            }

            Customer.AccountType account = Customer.AccountType.Limited;
            switch (row["account_type"].ToString())
            {
            case "Disabled":
                account = Customer.AccountType.Disabled;
                break;

            case "Limited":
                account = Customer.AccountType.Limited;
                break;

            case "Bronze":
                account = Customer.AccountType.Bronze;
                break;

            case "Silver":
                account = Customer.AccountType.Silver;
                break;

            case "Gold":
                account = Customer.AccountType.Gold;
                break;

            default:
                return(null);
            }

            UserName name    = new UserName(firstName, lastName);
            Address  address = new Address(suite, street, house, city, province, postalCode);

            ContactInformation newContact = new ContactInformation(email, phone);

            Credentials credentials = new Credentials(row["username"].ToString(), row["passhash"].ToString());

            Customer customer = new Customer(name, address, newContact, account)
            {
                CreationDate = creationDate,
                CreditCard   = creditCard,
                Id           = (int)row["cid"],
                Rating       = (int)row["rating"],
                Credentials  = credentials,
            };

            return(customer);
        }