1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using AvaloniaApplication1.Models;
- using MsBox.Avalonia.Enums;
- using MsBox.Avalonia;
- using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal;
- using ReactiveUI;
- namespace AvaloniaApplication1.ViewModels
- {
- public class AuthorizationViewModel : ReactiveObject
- {
- public static ScoolContext DB = new ScoolContext();
- private string _login;
- private string _pass;
- public string Login
- {
- get => _login; set => this.RaiseAndSetIfChanged(ref _login, value);
- }
- public string Pass
- {
- get => _pass; set => this.RaiseAndSetIfChanged(ref _pass, value);
- }
- public int Auth()
- {
- if(Login != null && Pass!=null)
- {
- User user = DB.Users.Where(x=>x.Login == Login && x.Password == Pass).FirstOrDefault();
- if(user != null)
- {
- return user.IdUser;
- }
- else
- {
- var box = MessageBoxManager.GetMessageBoxStandard("Ïðåäóïðåæäåíèå", "Âàñ íåò");
- box.ShowAsync();
- return 0;
- }
- }
- else
- {
- var box = MessageBoxManager.GetMessageBoxStandard("Ïðåäóïðåæäåíèå", "Ïîëÿ íå çàïîëíåíû");
- box.ShowAsync();
- return 0;
- }
- }
- }
- }
|