demo_term/demko_term/ViewApplicantWindow.axaml.cs
2025-04-14 11:28:12 +03:00

59 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using demko_term.Models;
using Microsoft.EntityFrameworkCore;
namespace demko_term;
public partial class ViewApplicantWindow : Window
{
private List<Applicant> dataSourceApplicants;
public ViewApplicantWindow()
{
InitializeComponent();
using var context = new DemoCourseworkContext();
DisplayApplicant();
}
public void LoadData()
{
using var context = new DemoCourseworkContext();
dataSourceApplicants = context.Applicants
.Select(a => new Applicant
{
Id = a.Id,
Firstname = a.Firstname,
Lastname = a.Lastname,
Patronymic = a.Patronymic,
Code = a.Code,
Date = a.Date,
Address = a.Address,
Email = a.Email,
Phone = a.Phone
}).ToList();
}
public void DisplayApplicant()
{
LoadData();
var temp = dataSourceApplicants;
ApplicantListBox.ItemsSource = temp;
}
private async void CreateApplicantWindowButton_OnClick(object? sender, RoutedEventArgs e)
{
CreateApplicantWindow сreateApplicantWindow = new CreateApplicantWindow();
await сreateApplicantWindow.ShowDialog(this);
DisplayApplicant();
}
}