feat: implement core domain models, authentication service, and UI components for the attendance system
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Asistencia.ViewModels;
|
||||
using Asistencia.Views;
|
||||
using Asistencia.Data;
|
||||
using Asistencia.Data.Repositories;
|
||||
using Asistencia.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Asistencia;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public static IServiceProvider? Services { get; private set; }
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddDbContext<AppDbContext>();
|
||||
services.AddSingleton<ProfesorRepository>();
|
||||
services.AddSingleton<CursoRepository>();
|
||||
services.AddSingleton<AsistenciaRepository>();
|
||||
services.AddSingleton<AuthService>();
|
||||
services.AddSingleton<AsistenciaService>();
|
||||
services.AddSingleton<MainWindowViewModel>();
|
||||
|
||||
Services = services.BuildServiceProvider();
|
||||
|
||||
using var scope = Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
db.Database.EnsureCreated();
|
||||
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var vm = Services.GetRequiredService<MainWindowViewModel>();
|
||||
desktop.MainWindow = new MainWindow
|
||||
{
|
||||
DataContext = vm
|
||||
};
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user