Пример #1
0
 private bool IsUserExits(User anUser)
 {
     User user = userGateway.GetUserByEmail(anUser.Email);
     if (user != null)
     {
         return true;
     }
     return false;
 }
Пример #2
0
 protected void registerButton_Click(object sender, EventArgs e)
 {
     string userId = Guid.NewGuid().ToString().Replace("-","").ToUpper();
     string userName = userNameTextBox.Text;
     string email = emailTextBox.Text;
     string password = passwordTextBox.Text;
     User anUser=new User(userId,userName,email,password);
     string messsage = userManager.Save(anUser);
     messageLabel.Text = messsage;
     ClearAllTextBox();
     //Response.Redirect("LogIn.aspx");
 }
Пример #3
0
 public int Insert(User anUser)
 {
     string query = "INSERT INTO t_Users VALUES(@userId,@userName,@email,@password)";
     CommandObj.CommandText = query;
     CommandObj.Parameters.Clear();
     CommandObj.Parameters.AddWithValue("@userId", anUser.UserId);
     CommandObj.Parameters.AddWithValue("@userName", anUser.UserName);
     CommandObj.Parameters.AddWithValue("@email", anUser.Email);
     CommandObj.Parameters.AddWithValue("@password", anUser.Password);
     ConnectionObj.Open();
     int rowAffected = CommandObj.ExecuteNonQuery();
     return rowAffected;
 }
Пример #4
0
 public string Save(User anUser)
 {
     bool isUserExits = IsUserExits(anUser);
     if (isUserExits)
     {
         return "This email is already used by someone";
     }
     if (userGateway.Insert(anUser) > 0)
     {
         return "Registration sucessful";
     }
     return "Registration failed";
 }
Пример #5
0
 public User GetUserByEmail(string email)
 {
     string query = "SELECT * FROM t_Users WHERE Email=@email";
     CommandObj.CommandText = query;
     CommandObj.Parameters.Clear();
     CommandObj.Parameters.AddWithValue("@email", email);
     User anUser = null;
     ConnectionObj.Open();
     SqlDataReader reader = CommandObj.ExecuteReader();
     if (reader.Read())
     {
         anUser=new User();
         anUser.UserId = reader["UserId"].ToString();
         anUser.UserName = reader["UserName"].ToString();
         anUser.Email = reader["Email"].ToString();
         anUser.Password = reader["Password"].ToString();
     }
     reader.Close();
     CommandObj.Dispose();
     ConnectionObj.Close();
     return anUser;
 }