123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using AvaloniaApplication4.AdditionalModels;
- using AvaloniaApplication4.Models;
- using AvaloniaApplication4.Views;
- using Microsoft.EntityFrameworkCore;
- using ReactiveUI;
- using System.Collections.Generic;
- using System.Linq;
- namespace AvaloniaApplication4.ViewModels
- {
- public class MainWindowViewModel : ViewModelBase
- {
- private string? message = "";
- public string? Login { get; set; }
- public string? Password { get; set; }
- public string? Message
- {
- get { return message; }
- set
- {
- if (message == value)
- return;
- message = value;
- OnPropertyChanged("Message");
- }
- }
- GlobalsData globalsData = new();
- public GlobalsData GlobalsData { get => globalsData; set => globalsData = value; }
- public MainWindowViewModel()
- {
- globalsData = new GlobalsData();
- //GlobalsData.GlobalUserControl = new StartPage(user);
- }
- public void Next()
- {
- try
- {
- UsersLogin? currentUser = dataBase.UsersLogins.FirstOrDefault(x => x.Password == Password && x.UserEmail == Login);
- User? user;
- if (currentUser == null) Message = "Неверный логин или пароль";
- else
- {
- Message = "";
- user = dataBase.Users.FirstOrDefault(x => x.IdUser == currentUser.IdUser);
- MainUserControl = new MainPage(user);
- }
- }
- catch { }
- }
- }
- }
|