public class PopupController : Controller
{
private readonly string ConnectionString;
public PopupController(IConfiguration configuration)
{
ConnectionString = configuration["ConnectionStrings:DefaultConnection"];
}
public IActionResult Index()
{
return View(GetEmployeeList());
}
private List<Users> GetEmployeeList()
{
MySqlConnection con = new MySqlConnection(ConnectionString);
MySqlCommand cmd = new MySqlCommand("SELECT tu.n_Userid,tu.s_FirstName,tu.s_Gender,tu.s_UserId FROM tb_Users tu", con);
con.Open();
MySqlDataReader idr = cmd.ExecuteReader();
List<Users> users = new List<Users>();
if (idr.HasRows)
{
while (idr.Read())
{
users.Add(new Users
{
UserId = Convert.ToInt32(idr["n_Userid"]),
Name = Convert.ToString(idr["s_FirstName"]),
Gender = Convert.ToString(idr["s_Gender"]),
UserName = Convert.ToString(idr["s_UserId"]),
});
}
}
con.Close();
return users;
}
public IActionResult UserPageView(int id)
{
Users Users = new Users();
MySqlConnection con = new MySqlConnection(ConnectionString);
MySqlCommand cmd = new MySqlCommand("SELECT tu.n_Userid,tu.s_FirstName,tu.s_Gender,tu.s_UserId,s_Password FROM tb_Users tu where n_Userid ='" + Convert.ToInt32(id) + "'", con);
con.Open();
MySqlDataReader idr = cmd.ExecuteReader();
List<Users> users = new List<Users>();
if (idr.HasRows)
{
idr.Read();
Users.UserName = Convert.ToString(idr["s_UserId"]);
Users.Password = Convert.ToString(idr["s_Password"]);
}
con.Close();
return PartialView("_PartialViewUser", Users);
}
}