using System; using System.Collections.Generic; using System.Linq; using Acosta.Models; using ReactiveUI; namespace Acosta.ViewModels { public class UserViewModel : ReactiveObject { SuharevaContext myConnection; Employee? currentUser; public UserViewModel(SuharevaContext myC) { this.myConnection = myC; CurrentUser = new Employee(); } public UserViewModel(SuharevaContext myConnection, int id, string password) { this.myConnection = myConnection; currentUser = myConnection.Employees.FirstOrDefault(x => x.Employeesid == id); if (password == CurrentUser.Password) { currentUser.Surname = currentUser.Surname; currentUser.Name = currentUser.Name; currentUser.Patronymic = currentUser.Patronymic; currentUser.Email = currentUser.Email; currentUser.Phonenumber = currentUser.Phonenumber; currentUser.Role = currentUser.Role; currentUser.Password = password; myConnection.SaveChanges(); } } public Employee? CurrentUser { get => currentUser; set => currentUser = value; } } }