Auth.xaml.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace ModuleExam
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для Auth.xaml
  19. /// </summary>
  20. public partial class Auth : Page
  21. {
  22. ExamEntities DB = new ExamEntities();
  23. public Auth()
  24. {
  25. InitializeComponent();
  26. }
  27. private void MakeAuth(object sender, RoutedEventArgs e)
  28. {
  29. int id = CheckOnExisting(Email.Text, Pass.Password);
  30. if (id !=-1)
  31. {
  32. MainFrame.MFrame.Navigate(new ActivityPage(id));
  33. }
  34. else
  35. {
  36. MessageBox.Show("Вас не в системе");
  37. }
  38. }
  39. public int CheckOnExisting(string Mail, string Password)
  40. {
  41. users user = new users();
  42. user = DB.users.Where(x => x.email == Mail && x.password == Password).FirstOrDefault();
  43. if(user != null)
  44. {
  45. return user.id;
  46. }
  47. else { return -1; }
  48. }
  49. }
  50. }