Ejemplo n.º 1
0
        public void SignUp(string login, string password, string firstName, string lastName, string birth, string email, string phone)
        {
            using (CinemaEntities database = new CinemaEntities())
            {
                Customer newCustomer = database.Customer.Create();

                newCustomer.Customer_ID = Convert.ToInt32(database.sp_getSeqCustomerID().FirstOrDefault());
                newCustomer.Login       = login;
                newCustomer.Password    = password;
                newCustomer.First_Name  = firstName;
                newCustomer.Last_Name   = lastName;
                newCustomer.Birth       = DateTime.Parse(birth);
                newCustomer.Email       = email;
                newCustomer.Phone       = phone;
                newCustomer.Role_ID     = 1;

                // jeśli zajęty
                if (CustomerExist(login))
                {
                    MessageBox.Show("User name is already taken");
                }
                // jeśli nie jest zajęty
                else
                {
                    database.Customer.Add(newCustomer);
                    database.SaveChanges();
                    MessageBox.Show("Account created");
                }
            }
        }