1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using pr13.Models;
- using MsBox.Avalonia.Enums;
- using MsBox.Avalonia;
- using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal;
- using ReactiveUI;
- namespace pr13.ViewModels
- {
- public class AuthViewModel : ReactiveObject
- {
- public static PostgresContext DB = new PostgresContext();
- 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;
- }
- }
- }
- }
|