addDataGrid
This commit is contained in:
parent
908715ff15
commit
8648e3efaf
@ -1,45 +0,0 @@
|
|||||||
using domain.Service;
|
|
||||||
using domain.UseCase;
|
|
||||||
using domain.Request;
|
|
||||||
using domain.Service;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Presence.Api.Response;
|
|
||||||
|
|
||||||
namespace Presence.Api.Controllers
|
|
||||||
{
|
|
||||||
[ApiController]
|
|
||||||
[Route("[controller]/api")]
|
|
||||||
public class GroupController: ControllerBase
|
|
||||||
{
|
|
||||||
private readonly IGroupUseCase _groupService;
|
|
||||||
|
|
||||||
public GroupController(IGroupUseCase groupService)
|
|
||||||
{
|
|
||||||
_groupService = groupService;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("/group")]
|
|
||||||
public async Task<ActionResult<GroupResponse>> GetAllGroups()
|
|
||||||
{
|
|
||||||
var result = _groupService
|
|
||||||
.GetGroupsWithStudents();
|
|
||||||
var response = result
|
|
||||||
.Select(group => new GroupResponse {
|
|
||||||
Id = group.Id,
|
|
||||||
Name = group.Name,
|
|
||||||
Users = group.Users.Select(user => new UserResponse {
|
|
||||||
Guid = user.Guid,
|
|
||||||
Name = user.Name
|
|
||||||
}).ToList(),
|
|
||||||
}).ToList();
|
|
||||||
return Ok(new GroupResponse());
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("/admin/{groupId}/students")]
|
|
||||||
public void AddGroup(int groupId, [FromBody] AddGroupRequest addGroupRequest)
|
|
||||||
{
|
|
||||||
Console.WriteLine(groupId);
|
|
||||||
_groupService.AddGroup(addGroupRequest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace Presence.Api.Controllers
|
|
||||||
{
|
|
||||||
[ApiController]
|
|
||||||
[Route("[controller]")]
|
|
||||||
public class WeatherForecastController : ControllerBase
|
|
||||||
{
|
|
||||||
private static readonly string[] Summaries = new[]
|
|
||||||
{
|
|
||||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly ILogger<WeatherForecastController> _logger;
|
|
||||||
|
|
||||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet(Name = "GetWeatherForecast")]
|
|
||||||
public IEnumerable<WeatherForecast> Get()
|
|
||||||
{
|
|
||||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
||||||
{
|
|
||||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
||||||
TemperatureC = Random.Shared.Next(-20, 55),
|
|
||||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
|
||||||
})
|
|
||||||
.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using data;
|
|
||||||
using data.Repository;
|
|
||||||
using domain.Service;
|
|
||||||
using domain.UseCase;
|
|
||||||
using Presence.Api.Controllers;
|
|
||||||
|
|
||||||
namespace Presence.Api.Extensions
|
|
||||||
{
|
|
||||||
public static class ServiceCollectionsExtension
|
|
||||||
{
|
|
||||||
public static void AddCommomService(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services
|
|
||||||
.AddDbContext<RemoteDatabaseContext>()
|
|
||||||
.AddScoped<IGroupRepository, SQLGroupRepository>()
|
|
||||||
.AddScoped<IGroupUseCase, GroupService>()
|
|
||||||
.AddScoped<GroupController>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\domain\domain.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Request\" />
|
|
||||||
<Folder Include="ServiceCollectionsExtension\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,6 +0,0 @@
|
|||||||
@Presence.Api_HostAddress = http://localhost:5028
|
|
||||||
|
|
||||||
GET {{Presence.Api_HostAddress}}/weatherforecast/
|
|
||||||
Accept: application/json
|
|
||||||
|
|
||||||
###
|
|
@ -1,29 +0,0 @@
|
|||||||
using Presence.Api.Extensions;
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
|
||||||
builder.Services.AddSwaggerGen();
|
|
||||||
|
|
||||||
builder.Services.AddCommomService();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (app.Environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
app.MapControllers();
|
|
||||||
|
|
||||||
app.Run();
|
|
@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:32613",
|
|
||||||
"sslPort": 44302
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
|
||||||
"http": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"applicationUrl": "http://localhost:5028",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"https": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"applicationUrl": "https://localhost:7098;http://localhost:5028",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace Presence.Api.Response
|
|
||||||
{
|
|
||||||
public class GroupResponse
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public IEnumerable<UserResponse>? Users { get; set; } = null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace Presence.Api.Response
|
|
||||||
{
|
|
||||||
public class UserResponse
|
|
||||||
{
|
|
||||||
public Guid Guid { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
namespace Presence.Api
|
|
||||||
{
|
|
||||||
public class WeatherForecast
|
|
||||||
{
|
|
||||||
public DateOnly Date { get; set; }
|
|
||||||
|
|
||||||
public int TemperatureC { get; set; }
|
|
||||||
|
|
||||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
|
||||||
|
|
||||||
public string? Summary { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Data.DAO;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Presence.Desktop.DI;
|
using Presence.Desktop.DI;
|
||||||
using Presence.Desktop.ViewModels;
|
using Presence.Desktop.ViewModels;
|
||||||
@ -18,13 +19,13 @@ namespace Presence.Desktop
|
|||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted()
|
||||||
{
|
{
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
serviceCollection.AddCommonService();
|
serviceCollection.AddPresenceService();
|
||||||
var services = serviceCollection.BuildServiceProvider();
|
var services = serviceCollection.BuildServiceProvider();
|
||||||
var maimViewModel = services.GetRequiredService<GroupViewModel>();
|
var maimViewModel = services.GetRequiredService<PresenceViewModel>();
|
||||||
|
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
desktop.MainWindow = new GroupView()
|
desktop.MainWindow = new PresenceView()
|
||||||
{
|
{
|
||||||
DataContext = maimViewModel,
|
DataContext = maimViewModel,
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,20 @@ namespace Presence.Desktop.DI
|
|||||||
.AddDbContext<RemoteDatabaseContext>()
|
.AddDbContext<RemoteDatabaseContext>()
|
||||||
.AddSingleton<IGroupRepository, SQLGroupRepository>()
|
.AddSingleton<IGroupRepository, SQLGroupRepository>()
|
||||||
.AddTransient<IGroupUseCase, GroupService>()
|
.AddTransient<IGroupUseCase, GroupService>()
|
||||||
|
.AddSingleton<SQLPresenceRepository>()
|
||||||
|
.AddTransient<PresenceService>()
|
||||||
.AddTransient<GroupViewModel>();
|
.AddTransient<GroupViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddPresenceService(this IServiceCollection collection)
|
||||||
|
{
|
||||||
|
collection
|
||||||
|
.AddDbContext<RemoteDatabaseContext>()
|
||||||
|
.AddSingleton<IGroupRepository, SQLGroupRepository>()
|
||||||
|
.AddTransient<IGroupUseCase, GroupService>()
|
||||||
|
.AddSingleton<SQLPresenceRepository>()
|
||||||
|
.AddTransient<PresenceService>()
|
||||||
|
.AddTransient<PresenceViewModel>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,18 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Data.DAO;
|
||||||
|
using Presense.Desktop.Models;
|
||||||
|
|
||||||
namespace Presence.Desktop.Models
|
namespace Presence.Desktop.Models
|
||||||
{
|
{
|
||||||
internal class GroupSubjectPresenter
|
public class GroupSubjectPresenter
|
||||||
{
|
{
|
||||||
|
public int GroupSubjectId { get; set; }
|
||||||
|
public int SemesterId { get; set; }
|
||||||
|
public SemesterPresenter Semester { get; set; }
|
||||||
|
public GroupPresenter Group { get; set; }
|
||||||
|
public SubjectPresenter Subject { get; set; }
|
||||||
|
public List<Attendance> Attendances { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,18 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Presense.Desktop.Models;
|
||||||
|
|
||||||
namespace Presence.Desktop.Models
|
namespace Presence.Desktop.Models
|
||||||
{
|
{
|
||||||
internal class PresencePresenter
|
public class PresencePresenter
|
||||||
{
|
{
|
||||||
|
public int AttendanceId { get; set; }
|
||||||
|
public DateOnly Date { get; set; }
|
||||||
|
public string Subject { get; set; }
|
||||||
|
public string StudentFullName { get; set; }
|
||||||
|
public string GroupName { get; set; }
|
||||||
|
public string PresenceType { get; set; }
|
||||||
|
public int LessonNumber { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Presence.Desktop.Models
|
namespace Presence.Desktop.Models
|
||||||
{
|
{
|
||||||
internal class SemesterPresenter
|
public class SemesterPresenter
|
||||||
{
|
{
|
||||||
|
public int SemesterId { get; set; }
|
||||||
|
public DateTime StartTime { get; set; }
|
||||||
|
public DateTime EndTime { get; set; }
|
||||||
|
public List<GroupSubjectPresenter> GroupSubjects { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Data.DAO;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -6,7 +7,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Presence.Desktop.Models
|
namespace Presence.Desktop.Models
|
||||||
{
|
{
|
||||||
class VisitPresenter
|
public class VisitPresenter
|
||||||
{
|
{
|
||||||
|
public int VisitId { get; set; }
|
||||||
|
public string VisitName { get; set; }
|
||||||
|
public List<Attendance> Attendances { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,8 @@ using System.Collections.ObjectModel;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace Presence.Desktop.ViewModels
|
namespace Presence.Desktop.ViewModels
|
||||||
{
|
{
|
||||||
@ -107,10 +105,10 @@ namespace Presence.Desktop.ViewModels
|
|||||||
|
|
||||||
private readonly string[] _sortingOptions = new[]
|
private readonly string[] _sortingOptions = new[]
|
||||||
{
|
{
|
||||||
"Без сортировки",
|
"Без сортировки",
|
||||||
"Фамилии (по возрастанию)",
|
"Фамилии (по возрастанию)",
|
||||||
"Фамилии (по убыванию)"
|
"Фамилии (по убыванию)"
|
||||||
};
|
};
|
||||||
|
|
||||||
public string[] SortingOptions => _sortingOptions;
|
public string[] SortingOptions => _sortingOptions;
|
||||||
|
|
||||||
|
@ -1,9 +1,126 @@
|
|||||||
using ReactiveUI;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using data.Repository;
|
||||||
|
using Data.DAO;
|
||||||
|
using domain.Service;
|
||||||
|
using domain.UseCase;
|
||||||
|
using Presence.Desktop.Models;
|
||||||
|
using Presense.Desktop.Models;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Presence.Desktop.ViewModels;
|
namespace Presence.Desktop.ViewModels;
|
||||||
|
|
||||||
public class PresenceViewModel : ViewModelBase, IRoutableViewModel
|
public class PresenceViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public string? UrlPathSegment { get; }
|
private readonly PresenceService _presenceService;
|
||||||
public IScreen HostScreen { get; }
|
private readonly IGroupUseCase _groupService;
|
||||||
|
private ObservableCollection<PresencePresenter> _presences;
|
||||||
|
private ObservableCollection<GroupPresenter> _groups;
|
||||||
|
private GroupPresenter? _selectedGroupItem;
|
||||||
|
private string? _selectedAttendanceType;
|
||||||
|
|
||||||
|
|
||||||
|
public ObservableCollection<PresencePresenter> Presences
|
||||||
|
{
|
||||||
|
get => _presences;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _presences, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<GroupPresenter> Groups => _groups;
|
||||||
|
|
||||||
|
public GroupPresenter? SelectedGroupItem
|
||||||
|
{
|
||||||
|
get => _selectedGroupItem;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_selectedGroupItem != value)
|
||||||
|
{
|
||||||
|
_selectedGroupItem = value;
|
||||||
|
this.RaisePropertyChanged();
|
||||||
|
UpdatePresences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] AttendanceTypes { get; } = { "Был", "Не был", "Болеет" };
|
||||||
|
|
||||||
|
public string? SelectedAttendanceType
|
||||||
|
{
|
||||||
|
get => _selectedAttendanceType;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.RaiseAndSetIfChanged(ref _selectedAttendanceType, value);
|
||||||
|
FilterPresences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PresenceViewModel(IGroupUseCase groupService, PresenceService presenceService)
|
||||||
|
{
|
||||||
|
_groupService = groupService;
|
||||||
|
_presenceService = presenceService;
|
||||||
|
_presences = new ObservableCollection<PresencePresenter>();
|
||||||
|
_groups = new ObservableCollection<GroupPresenter>();
|
||||||
|
|
||||||
|
LoadGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadGroups()
|
||||||
|
{
|
||||||
|
var groups = _groupService.GetGroupsWithStudents(); // Получаем все группы
|
||||||
|
_groups.Clear();
|
||||||
|
|
||||||
|
foreach (var group in groups)
|
||||||
|
{
|
||||||
|
_groups.Add(new GroupPresenter { GroupId = group.GroupId, GroupName = group.GroupName });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Выбираем первую группу по умолчанию
|
||||||
|
if (_groups.Any())
|
||||||
|
{
|
||||||
|
SelectedGroupItem = _groups.First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdatePresences()
|
||||||
|
{
|
||||||
|
if (SelectedGroupItem == null) return;
|
||||||
|
|
||||||
|
var PresencesListHere = _presenceService.GetAttendancesRelativeWithGroup(SelectedGroupItem.GroupId);
|
||||||
|
ObservableCollection<PresencePresenter> convertedList = new ObservableCollection<PresencePresenter>();
|
||||||
|
_presences.Clear();
|
||||||
|
|
||||||
|
foreach (var attendance in PresencesListHere)
|
||||||
|
{
|
||||||
|
convertedList.Add(convertToPresencePresenter(attendance));
|
||||||
|
}
|
||||||
|
|
||||||
|
Presences = convertedList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PresencePresenter convertToPresencePresenter(Attendance attendance)
|
||||||
|
{
|
||||||
|
return new PresencePresenter()
|
||||||
|
{
|
||||||
|
AttendanceId = attendance.AttendanceId,
|
||||||
|
StudentFullName = $"{attendance.Student.FirstName} {attendance.Student.LastName} {attendance.Student.Patronymic}",
|
||||||
|
Subject = attendance.GroupSubject.Subject.SubjectName,
|
||||||
|
Date = attendance.Date,
|
||||||
|
GroupName = attendance.Group.GroupName,
|
||||||
|
LessonNumber = attendance.LessonNumber,
|
||||||
|
PresenceType = attendance.Visit.VisitName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FilterPresences()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(SelectedAttendanceType)) return;
|
||||||
|
|
||||||
|
var filteredPresences = _presences.Where(a => a.PresenceType == SelectedAttendanceType).ToList();
|
||||||
|
_presences.Clear();
|
||||||
|
foreach (var attendance in filteredPresences)
|
||||||
|
{
|
||||||
|
_presences.Add(attendance);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -40,6 +40,10 @@
|
|||||||
<Button Content="Import students"
|
<Button Content="Import students"
|
||||||
Command="{Binding ImportStudentsCommand}"
|
Command="{Binding ImportStudentsCommand}"
|
||||||
Margin="10,0,0,0"/>
|
Margin="10,0,0,0"/>
|
||||||
|
|
||||||
|
<Button Content="Swap to presences"
|
||||||
|
Click="SwapToPresences"
|
||||||
|
Margin="10,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Border BorderBrush="Gray" BorderThickness="1" Margin="10" CornerRadius="5">
|
<Border BorderBrush="Gray" BorderThickness="1" Margin="10" CornerRadius="5">
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
using data;
|
||||||
|
using data.Repository;
|
||||||
|
using domain.Service;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Presence.Desktop.DI;
|
||||||
using Presence.Desktop.ViewModels;
|
using Presence.Desktop.ViewModels;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
@ -24,5 +31,26 @@ namespace Presence.Desktop.Views
|
|||||||
viewModel.UpdateSelectionStates();
|
viewModel.UpdateSelectionStates();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SwapToPresences(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var serviceCollection = new ServiceCollection();
|
||||||
|
serviceCollection.AddPresenceService();
|
||||||
|
var services = serviceCollection.BuildServiceProvider();
|
||||||
|
var presenceViewModel = services.GetRequiredService<PresenceViewModel>();
|
||||||
|
var window = new PresenceView
|
||||||
|
{
|
||||||
|
DataContext = presenceViewModel
|
||||||
|
|
||||||
|
};
|
||||||
|
window.Show();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,48 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:Presence.Desktop.ViewModels"
|
||||||
|
x:DataType="vm:PresenceViewModel"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Presence.Desktop.Views.PresenceView">
|
x:Class="Presence.Desktop.Views.PresenceView">
|
||||||
Welcome to Avalonia!
|
<StackPanel>
|
||||||
|
<!-- Верхняя панель с выбором группы и типа посещаемости -->
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="10">
|
||||||
|
<TextBlock Text="Группа:" VerticalAlignment="Center" Margin="0,0,5,0" />
|
||||||
|
<ComboBox ItemsSource="{Binding Groups}"
|
||||||
|
SelectedItem="{Binding SelectedGroupItem}"
|
||||||
|
Width="200" Margin="0,0,10,0">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding GroupName}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<TextBlock Text="Тип посещаемости:" VerticalAlignment="Center" Margin="0,0,5,0" />
|
||||||
|
<ComboBox ItemsSource="{Binding AttendanceTypes}"
|
||||||
|
SelectedItem="{Binding SelectedAttendanceType}"
|
||||||
|
Width="200" Margin="0,0,10,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
<TextBlock Text="PRivatik"/>
|
||||||
|
<Border BorderThickness="2" Background="Aqua">
|
||||||
|
<DataGrid Margin="20" ItemsSource="{Binding Presences}"
|
||||||
|
AutoGenerateColumns="True" IsReadOnly="True"
|
||||||
|
GridLinesVisibility="All" Height="300"
|
||||||
|
BorderThickness="1" BorderBrush="Gray">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="Ф.И.О." Binding="{Binding StudentFullName}" />
|
||||||
|
<DataGridTextColumn Header="Предмет" Binding="{Binding Subject}" />
|
||||||
|
<DataGridTextColumn Header="Дата" Binding="{Binding Date}" />
|
||||||
|
<DataGridTextColumn Header="Группа" Binding="{Binding GroupName}" />
|
||||||
|
<DataGridTextColumn Header="Номер урока" Binding="{Binding LessonNumber}" />
|
||||||
|
<DataGridTextColumn Header="Тип посещаемости" Binding="{Binding PresenceType}" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</Border>
|
||||||
|
<!-- DataGrid для отображения посещаемости -->
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -2,16 +2,17 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
using domain.Service;
|
||||||
|
using domain.UseCase;
|
||||||
using Presence.Desktop.ViewModels;
|
using Presence.Desktop.ViewModels;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Presence.Desktop.Views;
|
namespace Presence.Desktop.Views;
|
||||||
|
|
||||||
public partial class PresenceView : ReactiveUserControl<PresenceViewModel>
|
public partial class PresenceView : Window
|
||||||
{
|
{
|
||||||
public PresenceView()
|
public PresenceView()
|
||||||
{
|
{
|
||||||
this.WhenActivated(disposables => { });
|
InitializeComponent();
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,24 +22,5 @@ namespace console_ui
|
|||||||
Console.WriteLine("Enter group name: ");
|
Console.WriteLine("Enter group name: ");
|
||||||
_groupService.AddGroup(new domain.Request.AddGroupRequest { Name = Console.ReadLine() });
|
_groupService.AddGroup(new domain.Request.AddGroupRequest { Name = Console.ReadLine() });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddGroupWithStudents()
|
|
||||||
{
|
|
||||||
Console.WriteLine("Enter group name: ");
|
|
||||||
AddGroupRequest addGroupRequest = new AddGroupRequest { Name = Console.ReadLine() };
|
|
||||||
List<AddStudentRequest> addStudentRequests = new List<AddStudentRequest>()
|
|
||||||
{
|
|
||||||
new AddStudentRequest{ StudentName = "StudentName1"},
|
|
||||||
new AddStudentRequest{ StudentName = "StudentName2"},
|
|
||||||
new AddStudentRequest{ StudentName = "StudentName3"},
|
|
||||||
new AddStudentRequest{ StudentName = "StudentName4"},
|
|
||||||
};
|
|
||||||
AddGroupWithStudentsRequest addGroupWithStudents = new AddGroupWithStudentsRequest
|
|
||||||
{
|
|
||||||
addGroupRequest = addGroupRequest,
|
|
||||||
addStudentRequests = addStudentRequests
|
|
||||||
};
|
|
||||||
_groupService.AddGroupWithStudents(addGroupWithStudents);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
using console_ui;
|
using console_ui;
|
||||||
using data;
|
using data;
|
||||||
using data.DAO;
|
using Data.DAO;
|
||||||
using data.Repository;
|
using data.Repository;
|
||||||
using domain.Service;
|
using domain.Service;
|
||||||
using domain.UseCase;
|
using domain.UseCase;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
void printAllGroups(IGroupRepository groupRepository)
|
//void printAllGroups(IGroupRepository groupRepository)
|
||||||
{
|
//{
|
||||||
Console.WriteLine("Groups:");
|
// Console.WriteLine("Groups:");
|
||||||
foreach (var item in groupRepository.getAllGroup())
|
// foreach (var item in groupRepository.getAllGroup())
|
||||||
{
|
// {
|
||||||
Console.WriteLine(item.Name);
|
// Console.WriteLine(item.Name);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
IServiceCollection serviceCollection = new ServiceCollection();
|
//IServiceCollection serviceCollection = new ServiceCollection();
|
||||||
|
|
||||||
serviceCollection
|
//serviceCollection
|
||||||
.AddDbContext<RemoteDatabaseContext>()
|
// .AddDbContext<RemoteDatabaseContext>()
|
||||||
.AddSingleton<IGroupRepository, SQLGroupRepository>()
|
// .AddSingleton<IGroupRepository, SQLGroupRepository>()
|
||||||
.AddSingleton<IGroupUseCase, GroupService>()
|
// .AddSingleton<IGroupUseCase, GroupService>()
|
||||||
.AddSingleton<GroupUI>();
|
// .AddSingleton<GroupUI>();
|
||||||
|
|
||||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
//var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||||
var groupUI = serviceProvider.GetService<GroupUI>();
|
//var groupUI = serviceProvider.GetService<GroupUI>();
|
||||||
groupUI?.AddGroup();
|
//groupUI?.AddGroup();
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,11 +3,32 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Data.DAO;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace data.Repository
|
namespace data.Repository
|
||||||
{
|
{
|
||||||
public class SQLPresenceRepository
|
public class SQLPresenceRepository
|
||||||
{
|
{
|
||||||
private readonly RemoteDatabaseContext _dbContext;
|
private readonly RemoteDatabaseContext _dbContext;
|
||||||
|
|
||||||
|
public SQLPresenceRepository(RemoteDatabaseContext remoteDatabaseContext)
|
||||||
|
{
|
||||||
|
_dbContext = remoteDatabaseContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Attendance> GetAllPresences()
|
||||||
|
{
|
||||||
|
var result = _dbContext.Attendances
|
||||||
|
.Include(attendance => attendance.GroupSubject)
|
||||||
|
.ThenInclude(groupSubject => groupSubject.Subject)
|
||||||
|
.Include(groupSubject => groupSubject.GroupSubject.Semester)
|
||||||
|
.Include(attendance => attendance.Student)
|
||||||
|
.Include(attendance => attendance.Group)
|
||||||
|
.Include(attendance => attendance.Visit);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ using data.Repository;
|
|||||||
|
|
||||||
namespace domain.Service
|
namespace domain.Service
|
||||||
{
|
{
|
||||||
class PresenceService
|
public class PresenceService
|
||||||
{
|
{
|
||||||
private readonly SQLPresenceRepository _presenceRepository;
|
private readonly SQLPresenceRepository _presenceRepository;
|
||||||
|
|
||||||
@ -21,5 +21,10 @@ namespace domain.Service
|
|||||||
{
|
{
|
||||||
return _presenceRepository.GetAllPresences().ToList();
|
return _presenceRepository.GetAllPresences().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Attendance> GetAttendancesRelativeWithGroup(int groupId)
|
||||||
|
{
|
||||||
|
return _presenceRepository.GetAllPresences().Where(pres => pres.Group.GroupId == groupId).ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "data", "data\data.csproj",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "domain", "domain\domain.csproj", "{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "domain", "domain\domain.csproj", "{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Presence.Api", "Presence.Api\Presence.Api.csproj", "{0493354A-C0C0-49FC-A143-28F2268309E2}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63} = {78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Presence.Desktop", "Presence.Desktop\Presence.Desktop.csproj", "{D646BC7E-8025-4985-AF9B-5E4474AD7F66}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Presence.Desktop", "Presence.Desktop\Presence.Desktop.csproj", "{D646BC7E-8025-4985-AF9B-5E4474AD7F66}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
@ -34,10 +29,6 @@ Global
|
|||||||
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}.Release|Any CPU.Build.0 = Release|Any CPU
|
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{0493354A-C0C0-49FC-A143-28F2268309E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{0493354A-C0C0-49FC-A143-28F2268309E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{0493354A-C0C0-49FC-A143-28F2268309E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{0493354A-C0C0-49FC-A143-28F2268309E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{D646BC7E-8025-4985-AF9B-5E4474AD7F66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{D646BC7E-8025-4985-AF9B-5E4474AD7F66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{D646BC7E-8025-4985-AF9B-5E4474AD7F66}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D646BC7E-8025-4985-AF9B-5E4474AD7F66}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D646BC7E-8025-4985-AF9B-5E4474AD7F66}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D646BC7E-8025-4985-AF9B-5E4474AD7F66}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
Loading…
Reference in New Issue
Block a user