Add initial project structure with basic view models, views, and resources

This commit is contained in:
2026-09-14 19:46:46 +03:00
commit 45401645c6
68 changed files with 2538 additions and 0 deletions
@@ -0,0 +1,53 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CryptoPortfolio_Tracker.Views;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls.Notifications;
using CryptoPortfolio_Tracker.Context;
using CryptoPortfolio_Tracker.Core;
using Microsoft.EntityFrameworkCore;
namespace CryptoPortfolio_Tracker.ViewModels
{
public partial class LoginViewModel : ObservableValidator
{
[Required] [ObservableProperty] public partial string Login { get; set; } = "admin";
[Required] [ObservableProperty] public partial string Password { get; set; } = "admin";
[RelayCommand]
private async Task LoginAsync()
{
if (Validate())
{
await using CryptoContext context = new();
var user = await context.Users.FirstOrDefaultAsync(u =>
(u.Email == Login || u.Login == Login) && u.Password == Password);
if (user == null)
{
MainView.Current.ShowToast("Неверный логин или пароль", NotificationType.Error);
return;
}
AppState.CurrentUser = user;
await MainView.Current.ReplaceAsync(new HomeView
{
DataContext = new HomeViewModel()
});
}
}
private bool Validate()
{
ValidateAllProperties();
return !HasErrors;
}
}
}