RedactAuth.xaml.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. namespace SneakersSkakunov
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для RedactAuth.xaml
  19. /// </summary>
  20. public partial class RedactAuth : Window
  21. {
  22. Sniker snk = new Sniker();
  23. Users user = new Users();
  24. public RedactAuth(int UsId)
  25. {
  26. InitializeComponent();
  27. user = snk.Users.Where(x => x.id_Users == UsId).FirstOrDefault();
  28. lg.Text = user.Login.ToString();
  29. }
  30. private void FixChange(object sender, RoutedEventArgs e)
  31. {
  32. user.Login = lg.Text;
  33. string CurPass = pss.Text;
  34. using (SHA256 hash = SHA256.Create())
  35. {
  36. CurPass = BitConverter.ToString(hash.ComputeHash(Encoding.UTF8.GetBytes(CurPass))).Replace("-", "");
  37. }
  38. user.Password = CurPass;
  39. snk.SaveChanges();
  40. MainFrame.mframe.Navigate(new UserPage(user.id_Users));
  41. MessageBox.Show("Изменения сохранены");
  42. }
  43. private void Back(object sender, RoutedEventArgs e)
  44. {
  45. this.Close();
  46. }
  47. }
  48. }