Advertisement
GoToDark

Untitled

Aug 6th, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Personal.Movie.Database.Model.UserModel;
  6. using MySql.Data.MySqlClient;
  7. using Dapper;
  8.  
  9. namespace Personal.Movie.Database.DBConnection
  10. {
  11. public class ManageUser
  12. {
  13. public static async Task<List<ValidateUserResult>> ValidateUserNameAndPassword(string connectionString, string userName,
  14. string userPassword) {
  15. using (MySqlConnection mysqlConnection = new MySqlConnection(connectionString))
  16. {
  17. try
  18. {
  19. mysqlConnection.Open();
  20. List<ValidateUserResult> validateUserResult = (await mysqlConnection.QueryAsync<ValidateUserResult>(
  21. @"select userID, userName, roleID, roleName
  22. from wyhdb.User u, wyhdb.Role r
  23. where u.userRoleID = r.roleID
  24. and u.userName = @userName
  25. and u.userPassword = @userPassword",
  26. new
  27. {
  28. userName = userName,
  29. userPassword = userPassword
  30. })).ToList();
  31. return validateUserResult;
  32. }
  33. catch (Exception ex)
  34. {
  35. return null;
  36. }
  37. finally {
  38. mysqlConnection.Close();
  39. }
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement