Esempio n. 1
0
        public void CreateUser(User user)
        {
            using (var conToDb = new SqlConnection(ConStr))
            {
                conToDb.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO dbo.Users (Login, Password, Name, LastName, Email, CreatedDate, LastLoginDate) VALUES (@Login, @Password, @Name, @Lastname, @Email, @CreatedDate, @LastLoginDate )", conToDb);
                cmd.Parameters.Add(new SqlParameter("@Login", user.Login));
                cmd.Parameters.Add(new SqlParameter("@Password", user.Password));
                cmd.Parameters.Add(new SqlParameter("@Name", user.Name));
                cmd.Parameters.Add(new SqlParameter("@Lastname", user.LastName));
                cmd.Parameters.Add(new SqlParameter("@Email", user.Email));
                cmd.Parameters.Add(new SqlParameter("@CreatedDate", user.CreatedDate));
                cmd.Parameters.Add(new SqlParameter("@LastLoginDate", user.LastLoginDate));

                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 2
0
 public User GetUser(string username)
 {
     var dBUsers = dbUser.GetUser(username);
     if (dBUsers.Count != 0)
     {
         var dbuser = dBUsers.FirstOrDefault();
         string _username = dbuser.Login;
         int _providerUserKey = dbuser.Id;
         string _email = dbuser.Email;
         string _passwordQuestion = "";
         string _comment = "";
         bool _isApproved = false;
         bool _isLockedOut = false;
         DateTime _creationDate = (DateTime)dbuser.CreatedDate;
         DateTime _lastLoginDate = DateTime.Now;
         DateTime _lastActivityDate = DateTime.Now;
         DateTime _lastPasswordChangedDate = DateTime.Now;
         DateTime _lastLockedOutDate = DateTime.Now;
         User user = new User("CustomMembershipProvider",
                                                     _username,
                                                     _providerUserKey,
                                                     _email,
                                                     _passwordQuestion,
                                                     _comment,
                                                     _isApproved,
                                                     _isLockedOut,
                                                     _creationDate,
                                                     _lastLoginDate,
                                                     _lastActivityDate,
                                                     _lastPasswordChangedDate,
                                                     _lastLockedOutDate);
         return user;
     }
     else
     {
         return null;
     }
 }
Esempio n. 3
0
 public User CreateUser(string username, string password, string email)
 {
     User user = new User();
     user.Login = username;
     user.Password = CreatePasswordHash(password);
     user.Name = "";
     user.LastName = "";
     user.Email = email;
     user.CreatedDate = DateTime.Now;
     user.LastLoginDate = DateTime.Now;
     dbUser.CreateUser(user);
     SendEmail("Thank you for our register in our site", "Now you to enter in our site", email);
     return GetUser(username);
 }