Page2NextViewModel.cs 1.1 KB

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Avalonia.Media.Imaging;
  5. using Microsoft.EntityFrameworkCore;
  6. using reactivepril.Models;
  7. using ReactiveUI;
  8. namespace reactivepril.ViewModels
  9. {
  10. public class Page2NextViewModel : ViewModelBase
  11. {
  12. Galochkin41pContext db = new Galochkin41pContext();
  13. User currentUser;
  14. Bitmap imgage;
  15. public User CurrentUser { get => currentUser; set => this.RaiseAndSetIfChanged(ref currentUser, value); }
  16. public Bitmap Imgage { get => imgage; set => this.RaiseAndSetIfChanged(ref imgage, value); }
  17. public Page2NextViewModel(int idUser)
  18. {
  19. CurrentUser = db.Users.Include(x => x.GendersNavigation).Include(x => x.RolesNavigation).FirstOrDefault(x => x.UserId == idUser);
  20. }
  21. public void GoBack() => MainWindowViewModel.Self.Page = new Page1();
  22. public List<string> Genders => db.Genders.Select(x => x.NameGender).ToList();
  23. public string GenderIndex { get => currentUser.GendersNavigation.NameGender; set => currentUser.Genders = db.Genders.FirstOrDefault(x => x.NameGender == value).IdGender; }
  24. }
  25. }