public IsExistUserServiceModel IsExist(int id) { IsExistUserServiceModel user = null; using (SqlConnection conn = new SqlConnection(connString)) { SqlCommand cmd = new SqlCommand("tdb_usr_ex", conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); cmd.Parameters.AddWithValue("@id", id); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { if (reader.HasRows) { user = new IsExistUserServiceModel { Id = int.Parse(reader["user_id"].ToString()), Username = reader["username"].ToString(), Password = reader["password"].ToString() }; } } } conn.Close(); } return(user); }
private bool CheckIfUserExist(int id) { IsExistUserServiceModel user = this.userService.IsExist(id); return(user != null ? true : false); }