EditEmployeeViewModel.cs 723 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Acosta.Models;
  5. using Acosta.Views;
  6. using Avalonia.Controls;
  7. using Microsoft.EntityFrameworkCore;
  8. using ReactiveUI;
  9. namespace Acosta.ViewModels
  10. {
  11. public class EditEmployeeViewModel : ReactiveObject
  12. {
  13. SuharevaContext myC;
  14. Employee? currentUser;
  15. public EditEmployeeViewModel(SuharevaContext myC, int userId)
  16. {
  17. this.myC = myC;
  18. currentUser = myC.Employees.Include(x => x.RoleNavigation).FirstOrDefault(x => x.Employeesid == userId);
  19. }
  20. public List<Role> Roles => myC.Roles.ToList();
  21. public Employee? CurrentUser { get => currentUser; set => currentUser = value; }
  22. }
  23. }