RedAutnInfoWin.xaml.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 MusicSmth
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для RedAutnInfoWin.xaml
  19. /// </summary>
  20. public partial class RedAutnInfoWin : Window
  21. {
  22. Music Muse = new Music();
  23. Users user = new Users();
  24. public RedAutnInfoWin(int UsId)
  25. {
  26. InitializeComponent();
  27. user = Muse.Users.Where(x => x.Id == UsId).FirstOrDefault();
  28. Login.Text = user.Login.ToString();
  29. }
  30. private void FixChange(object sender, RoutedEventArgs e)
  31. {
  32. user.Login = Login.Text;
  33. string CurPass = Pass.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. Muse.SaveChanges();
  40. MainFrame.mframe.Navigate(new UserPage(user.Id));
  41. MessageBox.Show("Изменения успешно сохранены");
  42. }
  43. private void Back(object sender, RoutedEventArgs e)
  44. {
  45. this.Close();
  46. }
  47. }
  48. }