public MembershipUser CreateUser(string username, string password, string email)
        {
            using (ApplicationServices db = new ApplicationServices())
            {
                User user = new User();

                user.Name = "";
                user.Username = username;
                user.Email = email;
                user.PasswordSalt = CreateSalt();
                user.Password = CreatePasswordHash(password, user.PasswordSalt);
                user.CreatedAt = DateTime.Now;
                user.LastModifiedAt = DateTime.Now;
                user.IsActivated = false;
                user.IsLockedOut = false;
                user.LastLockedOutAt = DateTime.Now;
                user.LastLoginAt = DateTime.Now;
                user.NewPasswordRequestedAt = DateTime.Now;
                user.NewEmailKey = GenerateKey();

                db.Users.Add(user);
                db.SaveChanges();

                SendActivationEmail(user);
                    
                return GetUser(username);
            }
        }
        public bool ActivateUser(string username, string key)
        {
            using (ApplicationServices db = new ApplicationServices())
            {
                var result = from u in db.Users where (u.Username == username) select u;
                if (result.Count() != 0)
                {
                    var dbuser = result.First();
                    if (dbuser.NewEmailKey == key)
                    {
                        dbuser.IsActivated = true;
                        dbuser.LastModifiedAt = DateTime.Now;
                        dbuser.NewEmailKey = null;
                        db.SaveChanges();

                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }
        }