1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using HelloItQuantum.Function;
- using HelloItQuantum.Models;
- using HelloItQuantum.Views;
- using ReactiveUI;
- namespace HelloItQuantum.ViewModels
- {
- public class AuthViewModel : MainWindowViewModel
- {
- #region
- string nickname = "";
- List<string>? userNicknames = new List<string>();
- public string Nickname { get => nickname; set => SetProperty(ref nickname, value); }
- #endregion
- /// <summary>
- /// Ìåòîä, îáðàáàòûâàþùèé íàæàòèå íà êíîïêó Âîéòè
- /// </summary>
- public void Auth()
- {
- List<User>? users = WorkWithFile.GetAllUsers();
- if(users != null)
- {
- userNicknames = users.Select(it => it.Nickname).ToList();
- if (userNicknames.Contains(Nickname))
- {
- CurrentUser = users.FirstOrDefault(it => it.Nickname == Nickname);
- HomeVM = new HomeViewModel();
- PageSwitch.View = new HomeView();
- }
- else
- {
- Nickname = "";
- }
- }
- else
- {
- Nickname = "";
- }
- }
- /// <summary>
- /// Ìåòîä, îáðàáàòûâàþùèé íàæàòèå íà êíîïêó Íåò ïðîôèëÿ
- /// </summary>
- public void CreateProfile()
- {
- CreateProfileVM = new CreateProfileViewModel();
- PageSwitch.View = new CreateProfileView();
- }
- }
- }
|