internal static Customer createRandomCustomer()
 {
     Customer c = new Customer(Customer.Type.Regular, 0);
     c.FirstName = "FirstName";
     c.MiddleName = "MiddleName";
     c.LastName = "LastName";
     return c;
 }
        public static Customer CreateCustomer(Customer.Type type, string firstname, string lastname, int userId)
        {
            if ((firstname == null) || (firstname.Trim() == ""))
                throw new ArgumentNullException("firstname");

            if ((lastname == null) || (lastname.Trim() == ""))
                throw new ArgumentNullException("lastname");

            if (userId <= 0)
                throw new ArgumentNullException("userId");

            Customer newCustomer = new Customer(type, userId);
            newCustomer.FirstName = firstname.Trim();
            newCustomer.LastName = lastname.Trim();
            newCustomer.Save(userId); // The user is creating his own record
            return newCustomer;
        }
        public static void Save(Customer customer, int actionPerformerId)
        {
            if (customer == null)
                throw new ArgumentNullException("customer");

            customer.Save(actionPerformerId);
        }
示例#4
0
        private void map(DAL.CustomersDataContext dc, Customer customer, DAL.Customer dalCustomer, int actionPerformerId)
        {
            bool isNew = customer.Id == 0;
            bool isModified = false;

            if (dalCustomer.FirstName != customer.FirstName)
            {
                dalCustomer.FirstName = customer.FirstName;
                isModified = true;
            }

            if (dalCustomer.MiddleName != customer.MiddleName)
            {
                dalCustomer.MiddleName = customer.MiddleName;
                isModified = true;
            }

            if (dalCustomer.LastName != customer.LastName)
            {
                dalCustomer.LastName = customer.LastName;
                isModified = true;
            }

            DAL.CustomerType ct = customer.CustomerType.findCustomerType(dc);
            if ((dalCustomer.CustomerType == null) || (dalCustomer.CustomerType.Id != ct.Id))
            {
                dalCustomer.CustomerType = ct;
                isModified = true;
            }

            if (dalCustomer.Balance != customer.Balance)
            {
                dalCustomer.Balance = customer.Balance;
                isModified = true;
            }

            if (dalCustomer.UserId != customer.UserId)
            {
                dalCustomer.UserId = customer.UserId;
                isModified = true;
            }

            if (isNew)
            {
                dalCustomer.CreatedBy = actionPerformerId;
                dalCustomer.CreatedDate = DateTime.Now;
            }

            if (isModified)
            {
                dalCustomer.LastChangedBy = actionPerformerId;
                dalCustomer.LastChangedDate = DateTime.Now;
            }
        }
示例#5
0
        private static void map(DAL.Customer dalCustomer, DAL.CustomerType dalCustomerType,
            IEnumerable<Address> addresses, IEnumerable<Phone> phones, IEnumerable<Login> logins, Customer bo)
        {
            bo.Id = dalCustomer.Id;
            bo.FirstName = dalCustomer.FirstName;
            bo.MiddleName = dalCustomer.MiddleName;
            bo.LastName = dalCustomer.LastName;
            bo.CustomerType = (Type)Enum.Parse(typeof(Type), dalCustomerType.TypeName);
            bo.Balance = dalCustomer.Balance;
            bo.UserId = dalCustomer.UserId;

            bo.Addresses = new List<Address>(addresses);
            bo.Phones = new List<Phone>(phones);
            bo.Logins = new List<Login>(logins);
        }
示例#6
0
        internal static Customer LoadWithUserId(int userId)
        {
            DAL.CustomersDataContext dc = new DAL.CustomersDataContext();
            DAL.Customer c = findRecordByUserId(dc, userId);

            Customer bo = new Customer();
            map(c,
                dc.CustomerTypes.Where(ct => ct.Id == c.CustomerTypeId).Single(),
                Address.LoadWithCustomerId(dc, c.Id),
                Phone.LoadWithCustomerId(dc, c.Id),
                Login.LoadWithCustomerId(dc, c.Id),
                bo);

            return bo;
        }
示例#7
0
 public Customer(Customer.Type ct, int userId)
     : this()
 {
     this.CustomerType = ct;
     this.UserId = userId;
 }
示例#8
0
 public CreditsOrder(Customer customer, string orderID, string amount)
 {
     this.customer = customer;
     this.orderID  = orderID;
     this.amount   = amount;
 }