Guest User

Untitled

a guest
Nov 20th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using capaDALC;
  7. namespace capaLogicaNegocio
  8. {
  9. public class CL_Usuario
  10. {
  11. private string _usuario;
  12. private string _password;
  13. private string _nombre;
  14. private string _apellido;
  15.  
  16. public string Usuario
  17. {
  18. get
  19. {
  20. return _usuario;
  21. }
  22.  
  23. set
  24. {
  25. _usuario = value;
  26. }
  27. }
  28.  
  29. public string Password
  30. {
  31. get
  32. {
  33. return _password;
  34. }
  35.  
  36. set
  37. {
  38. _password = value;
  39. }
  40. }
  41.  
  42. public string Nombre
  43. {
  44. get
  45. {
  46. return _nombre;
  47. }
  48.  
  49. set
  50. {
  51. _nombre = value;
  52. }
  53. }
  54.  
  55. public string Apellido
  56. {
  57. get
  58. {
  59. return _apellido;
  60. }
  61.  
  62. set
  63. {
  64. _apellido = value;
  65. }
  66. }
  67.  
  68. private CL_Contexto conexion;
  69. public CL_Usuario()
  70. {
  71. conexion = new CL_Contexto();
  72. }
  73.  
  74. public CL_Usuario validarUsuario()
  75. {
  76. try
  77. {
  78. Usuario userBD = conexion.Entidades.Usuario.First(x => x.UserName == this.Usuario && x.Password == this.Password);
  79.  
  80.  
  81. return new CL_Usuario() { Nombre = userBD.Nombres, Apellido = userBD.Apellidos }; //se retorna un usuario con el nombre cargado
  82.  
  83. }
  84. catch (Exception ex)
  85. {
  86. return null;
  87. throw new Exception("Error al validar usuario" + ex.Message);
  88. }
  89.  
  90. }
  91.  
  92.  
  93. }
  94. }
Add Comment
Please, Sign In to add comment