internal static Customer GetCustomerOrCreateNotYetBuy(string phoneNumber)
        {
            Customer existCustomer;

            if (CustomerDAO.IsExist(phoneNumber))
            {
                existCustomer = CustomerDAO.GetObject(phoneNumber);
            }
            else
            {   
                /// Tạo User tương ứng
                User newUser = new User();
                newUser.Id = Guid.NewGuid();
                newUser.CreateDate = DateTime.Now;
                newUser.Username = phoneNumber;
                newUser.Password = "";
                newUser.Block = false;
                UserDAO.AddNew(newUser);


                ///Khởi tạo customer & gán status
                Customer newCustomer = new Customer();
                newCustomer.UserId = newUser.Id;
                newCustomer.PhoneNumber = phoneNumber;
                newCustomer.StatusId = CustomerStateDAO.GetObject("001").Id;

                CustomerDAO.AddNew(newCustomer);
                existCustomer = CustomerDAO.GetObject(phoneNumber);
            }
            return existCustomer;
        }
Esempio n. 2
0
 public static bool AddNew(User entity)
 {
     MoneyPacificDataContext mpdb = new MoneyPacificDataContext();
     mpdb.Users.InsertOnSubmit(entity);
     mpdb.SubmitChanges();
     mpdb.Connection.Close();
     return true;
 }
Esempio n. 3
0
        public static bool Update(User entity)
        {
            MoneyPacificDataContext mpdb = new MoneyPacificDataContext();
            
            User existUser = mpdb.Users
                .Where(p => p.Id.Equals(entity.Id))
                .Single<User>();
            existUser.CopyFrom(entity);
            mpdb.SubmitChanges();

            mpdb.Connection.Close();
            return true;
        }
Esempio n. 4
0
        public void CopyFrom(User entity)
        {
            this.Username = entity.Username;
            this.Password = entity.Password;

            this.Firstname = entity.Firstname;
            this.Lastname = entity.Lastname;

            this.Email = entity.Email;
            
            this.CreateDate = entity.CreateDate;            
            this.LastVisitDate = entity.LastVisitDate;
            this.Block = entity.Block;
            
        }
 partial void DeleteUser(User instance);
 partial void UpdateUser(User instance);
 partial void InsertUser(User instance);