public void UserClassTest()
        {
            // Arrange
            // Create the user.
            User user = new User();
            user.UserName = "******";
            user.Password = "******";
            user.FirstName = "Ke";
            user.LastName = "Sun";
            user.Email = "*****@*****.**";
            user.PrivilegeType = User.Privilege.Admin;
            user.RegistrationDate = DateTime.Now;
            user.LoginDate = DateTime.Now;

            // Act
            // Submit the user.
            try
            {
                using (DataContext userDataContext = new DataContext(Constants.DatabaseConnectionString))
                {
                    Table<User> userTable = userDataContext.GetTable<User>();

                    userTable.InsertOnSubmit(user);
                    userDataContext.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
            }

            user = null;

            // Retrieve the user.
            try
            {
                using (DataContext userDataContext = new DataContext(Constants.DatabaseConnectionString))
                {
                    Table<User> userTable = userDataContext.GetTable<User>();

                    user = (from userEntity in userTable where userEntity.UserName == "ksun" select userEntity).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
            }

            // Assert
            Assert.IsNotNull(user);
        }
 protected void Session_Start()
 {
     Session["User"] = new DomainModel.DataEntities.User();
 }
        public ActionResult Register(DomainModel.ValidationEntities.UserRegistration userReg)
        {
            if (ModelState.IsValid) // Validation (fields and username) is delegated to UserRegistration class.
            {
                // Save user registration to the database.
                DomainModel.DataEntities.User user = new Otakuwire.DomainModel.DataEntities.User();
                user.UserName = userReg.UserName;
                user.Password = userReg.Password; user.EncryptPassword();
                user.Email = userReg.Email;
                user.RegistrationDate = DateTime.Now;
                user.LoginDate = DateTime.Now;
                user.VoteQuota = 33;

                using (DataContext userDataContext = new DataContext(Constants.DatabaseConnectionString))
                {
                    Table<DomainModel.DataEntities.User> userTable = userDataContext.GetTable<DomainModel.DataEntities.User>();

                    userTable.InsertOnSubmit(user);
                    userDataContext.SubmitChanges();
                }

                user.LoggedIn = true;

                Session["User"] = user;

                return RedirectToAction("Index");
            }
            else
            {
                return View();
            }
        }