PersonalAccountViewModel.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using ReactiveUI;
  4. using Acosta.Models;
  5. using Microsoft.EntityFrameworkCore;
  6. using System.Linq;
  7. namespace Acosta.ViewModels
  8. {
  9. public class PersonalAccountViewModel : ReactiveObject
  10. {
  11. SuharevaContext myConnection;
  12. Employee currentUser;
  13. string oldPass;
  14. public string FIO;
  15. public PersonalAccountViewModel(SuharevaContext myConnection)
  16. {
  17. this.myConnection = myConnection;
  18. CurrentUser = new Employee();
  19. myConnection.Add(CurrentUser);
  20. }
  21. public PersonalAccountViewModel(SuharevaContext myConnection, int id)
  22. {
  23. this.myConnection = myConnection;
  24. CurrentUser = myConnection.Employees.FirstOrDefault(x => x.Employeesid == id);
  25. oldPass = CurrentUser.Password;
  26. CurrentUser.Surname = CurrentUser.Surname + " " + CurrentUser.Name.ToCharArray()[0] + ". " + CurrentUser.Patronymic.ToCharArray()[0] + ".";
  27. }
  28. public Employee CurrentUser { get => currentUser; set => currentUser = value; }
  29. }
  30. }