right-version
This commit is contained in:
parent
44d091674e
commit
b84da3b29a
@ -20,13 +20,13 @@ namespace Presence.Desktop
|
|||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
serviceCollection.AddCommonService();
|
serviceCollection.AddCommonService();
|
||||||
var services = serviceCollection.BuildServiceProvider();
|
var services = serviceCollection.BuildServiceProvider();
|
||||||
var mainViewModel = services.GetRequiredService<GroupViewModel>();
|
var maimViewModel = services.GetRequiredService<GroupViewModel>();
|
||||||
|
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
desktop.MainWindow = new MainWindow()
|
desktop.MainWindow = new GroupView()
|
||||||
{
|
{
|
||||||
DataContext = new MainWindowViewModel(services),
|
DataContext = maimViewModel,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
using Avalonia.Controls;
|
using System;
|
||||||
using ReactiveUI;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Presence.Desktop.Models
|
namespace Presense.Desktop.Models
|
||||||
{
|
{
|
||||||
public class GroupPresenter
|
public class GroupPresenter
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int GroupId { get; set; }
|
||||||
public string Name { get; set; }
|
public string GroupName { get; set; } = string.Empty;
|
||||||
public IEnumerable<UserPresenter>? users { get; set; } = null;
|
public List<StudentPresenter>? Students { get; set; } = null;
|
||||||
|
public List<SubjectPresenter> Subjects { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
Presence.Desktop/Models/StudentPresenter.cs
Normal file
19
Presence.Desktop/Models/StudentPresenter.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Presense.Desktop.Models
|
||||||
|
{
|
||||||
|
public class StudentPresenter
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string FirstName { get; set; } = string.Empty;
|
||||||
|
public string LastName { get; set; } = string.Empty;
|
||||||
|
public string Patronymic { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
// Ссылка на группу, к которой относится студент
|
||||||
|
public GroupPresenter? Group { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
Presence.Desktop/Models/SubjectPresenter.cs
Normal file
18
Presence.Desktop/Models/SubjectPresenter.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using domain.Entity;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Presense.Desktop.Models
|
||||||
|
{
|
||||||
|
public class SubjectPresenter
|
||||||
|
{
|
||||||
|
public int SubjectId { get; set; }
|
||||||
|
public string SubjectName { get; set; }
|
||||||
|
|
||||||
|
public int GroupId { get; set; }
|
||||||
|
public GroupEntity Group { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Presence.Desktop.Models
|
|
||||||
{
|
|
||||||
public class UserPresenter
|
|
||||||
{
|
|
||||||
public Guid Guid { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public GroupPresenter Group { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
37
Presence.Desktop/Presence - Backup.Desktop.csproj
Normal file
37
Presence.Desktop/Presence - Backup.Desktop.csproj
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AvaloniaResource Include="Assets\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="11.2.1" />
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="11.2.1" />
|
||||||
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1" />
|
||||||
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.1" />
|
||||||
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.1">
|
||||||
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\data\data.csproj" />
|
||||||
|
<ProjectReference Include="..\domain\domain.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Models\" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -7,13 +7,24 @@ using ReactiveUI;
|
|||||||
|
|
||||||
namespace Presence.Desktop
|
namespace Presence.Desktop
|
||||||
{
|
{
|
||||||
public class ViewLocator : IViewLocator
|
public class ViewLocator : IDataTemplate
|
||||||
{
|
{
|
||||||
public IViewFor? ResolveView<T>(T? viewModel, string? contract = null) => viewModel switch
|
public Control Build(object data)
|
||||||
{
|
{
|
||||||
GroupViewModel groupViewModel => new GroupView { DataContext = groupViewModel },
|
var name = data.GetType().FullName!.Replace("ViewModel", "View");
|
||||||
PresenceViewModel presenceViewModel => new PresenceView { DataContext = presenceViewModel },
|
var type = Type.GetType(name);
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(viewModel))
|
|
||||||
};
|
if (type != null)
|
||||||
|
{
|
||||||
|
return (Control)Activator.CreateInstance(type)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TextBlock { Text = "Not Found: " + name };
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Match(object data)
|
||||||
|
{
|
||||||
|
return data is ViewModelBase;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,100 +1,292 @@
|
|||||||
using domain.UseCase;
|
using Avalonia.Controls;
|
||||||
using Presence.Desktop.Models;
|
using domain.Request;
|
||||||
|
using domain.UseCase;
|
||||||
|
using Presense.Desktop.Models;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Presence.Desktop.ViewModels
|
namespace Presence.Desktop.ViewModels
|
||||||
{
|
{
|
||||||
public class GroupViewModel : ViewModelBase, IRoutableViewModel
|
public class GroupViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public ICommand OpenFileDialog { get; }
|
private readonly IGroupUseCase _groupService;
|
||||||
public Interaction<string?, string?> SelectFileInteraction => _SelectFileInteraction;
|
|
||||||
public readonly Interaction<string?, string?> _SelectFileInteraction;
|
|
||||||
private string? _selectedFile;
|
|
||||||
public string? SelectedFile
|
|
||||||
{
|
|
||||||
get => _selectedFile;
|
|
||||||
set => this.RaiseAndSetIfChanged(ref _selectedFile, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly List<GroupPresenter> _groupPresentersDataSource = new List<GroupPresenter>();
|
private readonly List<GroupPresenter> _groupPresentersDataSource = new();
|
||||||
private ObservableCollection<GroupPresenter> _groups;
|
private ObservableCollection<GroupPresenter> _groups;
|
||||||
public ObservableCollection<GroupPresenter> Groups => _groups;
|
public ObservableCollection<GroupPresenter> Groups => _groups;
|
||||||
|
|
||||||
|
private GroupPresenter? _selectedGroupItem;
|
||||||
public GroupPresenter? SelectedGroupItem
|
public GroupPresenter? SelectedGroupItem
|
||||||
{
|
{
|
||||||
get => _selectedGroupItem;
|
get => _selectedGroupItem;
|
||||||
set => this.RaiseAndSetIfChanged(ref _selectedGroupItem, value);
|
set
|
||||||
|
{
|
||||||
|
if (_selectedGroupItem != value)
|
||||||
|
{
|
||||||
|
_selectedGroupItem = value;
|
||||||
|
this.RaisePropertyChanged();
|
||||||
|
UpdateStudents();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GroupPresenter? _selectedGroupItem;
|
private ObservableCollection<StudentPresenter> _students;
|
||||||
|
public ObservableCollection<StudentPresenter> Students => _students;
|
||||||
|
|
||||||
|
public GroupViewModel() : this(null!) { }
|
||||||
private IGroupUseCase _groupUseCase;
|
|
||||||
public ObservableCollection<UserPresenter> Users { get => _users; }
|
|
||||||
public ObservableCollection<UserPresenter> _users;
|
|
||||||
public GroupViewModel(IGroupUseCase groupUseCase)
|
public GroupViewModel(IGroupUseCase groupUseCase)
|
||||||
{
|
{
|
||||||
_groupUseCase = groupUseCase;
|
_groupService = groupUseCase;
|
||||||
_SelectFileInteraction = new Interaction<string?, string?>();
|
|
||||||
OpenFileDialog = ReactiveCommand.CreateFromTask(SelectFile);
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
_users = new ObservableCollection<UserPresenter>();
|
|
||||||
RefreshGroups();
|
ImportStudentsCommand = ReactiveCommand.CreateFromTask(ImportStudentsAsync);
|
||||||
this.WhenAnyValue(vm => vm.SelectedGroupItem)
|
|
||||||
.Subscribe(_ =>
|
LoadGroupsAndStudents();
|
||||||
{
|
_students = new ObservableCollection<StudentPresenter>();
|
||||||
RefreshGroups();
|
RemoveAllStudentsCommand = ReactiveCommand.Create(RemoveAllStudents);
|
||||||
SetUsers();
|
|
||||||
});
|
RemoveSelectedStudentsCommand = ReactiveCommand.Create(RemoveSelectedStudents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUsers()
|
private void LoadGroupsAndStudents()
|
||||||
{
|
{
|
||||||
if (SelectedGroupItem == null) return;
|
foreach (var groupEntity in _groupService.GetGroupsWithStudents())
|
||||||
Users.Clear();
|
|
||||||
var group = _groups.First(it => it.Id == SelectedGroupItem.Id);
|
|
||||||
if (group.users == null) return;
|
|
||||||
foreach (var item in group.users)
|
|
||||||
{
|
{
|
||||||
Users.Add(item);
|
var groupPresenter = new GroupPresenter
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RefreshGroups()
|
|
||||||
{
|
|
||||||
_groupPresentersDataSource.Clear();
|
|
||||||
foreach (var item in _groupUseCase.GetGroupsWithStudents())
|
|
||||||
{
|
|
||||||
GroupPresenter groupPresenter = new GroupPresenter
|
|
||||||
{
|
{
|
||||||
Id = item.Id,
|
GroupId = groupEntity.GroupId,
|
||||||
Name = item.Name,
|
GroupName = groupEntity.GroupName,
|
||||||
users = item.Users?.Select(user => new UserPresenter
|
Students = groupEntity.Students?.Select(student => new StudentPresenter
|
||||||
{
|
{
|
||||||
Name = user.Name,
|
Id = student.Id,
|
||||||
Guid = user.Guid,
|
FirstName = student.FirstName,
|
||||||
Group = new GroupPresenter { Id = item.Id, Name = item.Name }
|
LastName = student.LastName,
|
||||||
}
|
Patronymic = student.Patronymic,
|
||||||
).ToList()
|
|
||||||
|
Group = null
|
||||||
|
}).ToList(),
|
||||||
|
Subjects = groupEntity.Subjects.Select(subject => new SubjectPresenter
|
||||||
|
{
|
||||||
|
SubjectId = subject.SubjectId,
|
||||||
|
SubjectName = subject.SubjectName
|
||||||
|
}).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
foreach (var student in groupPresenter.Students ?? Enumerable.Empty<StudentPresenter>())
|
||||||
|
{
|
||||||
|
student.Group = groupPresenter;
|
||||||
|
}
|
||||||
|
|
||||||
_groupPresentersDataSource.Add(groupPresenter);
|
_groupPresentersDataSource.Add(groupPresenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
_groups = new ObservableCollection<GroupPresenter>(_groupPresentersDataSource);
|
_groups = new ObservableCollection<GroupPresenter>(_groupPresentersDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SelectFile()
|
private void UpdateStudents()
|
||||||
{
|
{
|
||||||
Console.WriteLine("clock");
|
if (SelectedGroupItem?.Students == null) return;
|
||||||
SelectedFile = await _SelectFileInteraction.Handle("Chose csv file");
|
|
||||||
|
Students.Clear();
|
||||||
|
|
||||||
|
foreach (var student in SelectedGroupItem.Students)
|
||||||
|
{
|
||||||
|
Students.Add(student);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly string[] _sortingOptions = new[]
|
||||||
|
{
|
||||||
|
"Без сортировки",
|
||||||
|
"Фамилии (по возрастанию)",
|
||||||
|
"Фамилии (по убыванию)"
|
||||||
|
};
|
||||||
|
|
||||||
|
public string[] SortingOptions => _sortingOptions;
|
||||||
|
|
||||||
|
private string? _selectedSortingOption;
|
||||||
|
public string? SelectedSortingOption
|
||||||
|
{
|
||||||
|
get => _selectedSortingOption;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.RaiseAndSetIfChanged(ref _selectedSortingOption, value);
|
||||||
|
ApplySorting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplySorting()
|
||||||
|
{
|
||||||
|
if (SelectedGroupItem?.Students == null) return;
|
||||||
|
|
||||||
|
IEnumerable<StudentPresenter> sortedStudents = SelectedSortingOption switch
|
||||||
|
{
|
||||||
|
"Фамилии (по возрастанию)" => SelectedGroupItem.Students.OrderBy(s => s.LastName),
|
||||||
|
"Фамилии (по убыванию)" => SelectedGroupItem.Students.OrderByDescending(s => s.LastName),
|
||||||
|
_ => SelectedGroupItem.Students
|
||||||
|
};
|
||||||
|
|
||||||
|
Students.Clear();
|
||||||
|
foreach (var student in sortedStudents)
|
||||||
|
{
|
||||||
|
Students.Add(student);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> RemoveAllStudentsCommand { get; }
|
||||||
|
|
||||||
|
private void RemoveAllStudents()
|
||||||
|
{
|
||||||
|
if (SelectedGroupItem == null || SelectedGroupItem.Students == null) return;
|
||||||
|
|
||||||
|
_groupService.RemoveStudentsFromGroup(SelectedGroupItem.GroupId);
|
||||||
|
|
||||||
|
SelectedGroupItem.Students.Clear();
|
||||||
|
UpdateStudents();
|
||||||
|
LoadGroupsAndStudents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> ImportStudentsCommand { get; }
|
||||||
|
|
||||||
|
public async Task ImportStudentsAsync()
|
||||||
|
{
|
||||||
|
var dialog = new OpenFileDialog
|
||||||
|
{
|
||||||
|
Title = "Выберите файл CSV:",
|
||||||
|
Filters = new List<FileDialogFilter>
|
||||||
|
{
|
||||||
|
new FileDialogFilter { Name = "CSV Files", Extensions = { "csv" } }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await dialog.ShowAsync(new Window());
|
||||||
|
|
||||||
|
if (result != null && result.Any())
|
||||||
|
{
|
||||||
|
var filePath = result.First();
|
||||||
|
|
||||||
|
if (SelectedGroupItem == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Группа не выбрана.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var csvLines = File.ReadAllLines(filePath, Encoding.GetEncoding("windows-1251"));
|
||||||
|
|
||||||
|
var studentsToAdd = new List<AddStudentRequest>();
|
||||||
|
|
||||||
|
foreach (var line in csvLines)
|
||||||
|
{
|
||||||
|
var data = line.Split(';');
|
||||||
|
if (data.Length != 3)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Либо разделитель либо хз: {line}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
studentsToAdd.Add(new AddStudentRequest
|
||||||
|
{
|
||||||
|
FirstName = data[0],
|
||||||
|
LastName = data[1],
|
||||||
|
Patronymic = data[2]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (studentsToAdd.Any())
|
||||||
|
{
|
||||||
|
_groupService.AddStudentsToGroup(SelectedGroupItem.GroupId, studentsToAdd);
|
||||||
|
|
||||||
|
foreach (var studentRequest in studentsToAdd)
|
||||||
|
{
|
||||||
|
var studentPresenter = new StudentPresenter
|
||||||
|
{
|
||||||
|
FirstName = studentRequest.FirstName,
|
||||||
|
LastName = studentRequest.LastName,
|
||||||
|
Patronymic = studentRequest.Patronymic,
|
||||||
|
Group = SelectedGroupItem
|
||||||
|
};
|
||||||
|
|
||||||
|
SelectedGroupItem.Students.Add(studentPresenter);
|
||||||
|
Students.Add(studentPresenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateStudents();
|
||||||
|
LoadGroupsAndStudents();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Проблема с данными.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"...: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ObservableCollection<StudentPresenter> _selectedStudents = new();
|
||||||
|
public ObservableCollection<StudentPresenter> SelectedStudents
|
||||||
|
{
|
||||||
|
get => _selectedStudents;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.RaiseAndSetIfChanged(ref _selectedStudents, value);
|
||||||
|
UpdateSelectionStates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _isSingleSelection;
|
||||||
|
public bool IsSingleSelection
|
||||||
|
{
|
||||||
|
get => _isSingleSelection;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _isSingleSelection, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _isMultipleSelection;
|
||||||
|
public bool IsMultipleSelection
|
||||||
|
{
|
||||||
|
get => _isMultipleSelection;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _isMultipleSelection, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateSelectionStates()
|
||||||
|
{
|
||||||
|
IsSingleSelection = SelectedStudents.Count == 1;
|
||||||
|
IsMultipleSelection = SelectedStudents.Count > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> RemoveSelectedStudentsCommand { get; }
|
||||||
|
|
||||||
|
private void RemoveSelectedStudents()
|
||||||
|
{
|
||||||
|
if (SelectedStudents == null || SelectedStudents.Count == 0) return;
|
||||||
|
|
||||||
|
var studentIds = SelectedStudents.Select(s => s.Id).ToList();
|
||||||
|
_groupService.RemoveStudentsFromGroupByIds(SelectedGroupItem.GroupId, studentIds);
|
||||||
|
|
||||||
|
foreach (var student in SelectedStudents.ToList())
|
||||||
|
{
|
||||||
|
SelectedGroupItem.Students.Remove(student);
|
||||||
|
Students.Remove(student);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateStudents();
|
||||||
|
LoadGroupsAndStudents();
|
||||||
}
|
}
|
||||||
public string? UrlPathSegment { get; }
|
|
||||||
public IScreen HostScreen { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using ReactiveUI;
|
|
||||||
|
|
||||||
namespace Presence.Desktop.ViewModels;
|
|
||||||
|
|
||||||
public class MainWindowViewModel : ViewModelBase, IScreen
|
|
||||||
{
|
|
||||||
public RoutingState Router { get; } = new RoutingState();
|
|
||||||
|
|
||||||
public MainWindowViewModel(IServiceProvider serviceProvider)
|
|
||||||
{
|
|
||||||
var groupViewModel = serviceProvider.GetRequiredService<GroupViewModel>();
|
|
||||||
Router.Navigate.Execute(groupViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
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"
|
||||||
@ -8,38 +8,71 @@
|
|||||||
x:DataType="vm:GroupViewModel">
|
x:DataType="vm:GroupViewModel">
|
||||||
|
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
|
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||||
|
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||||
<vm:GroupViewModel/>
|
<vm:GroupViewModel/>
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
<DockPanel Background="Azure">
|
|
||||||
<StackPanel DockPanel.Dock="Bottom">
|
<DockPanel>
|
||||||
<TextBlock Text="List ↑" HorizontalAlignment="Center"/>
|
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="10">
|
||||||
</StackPanel>
|
<TextBlock Text="Group:" VerticalAlignment="Center" Margin="0,0,5,0" />
|
||||||
<StackPanel
|
|
||||||
Spacing="10"
|
|
||||||
HorizontalAlignment="Center"
|
<ComboBox ItemsSource="{Binding Groups}"
|
||||||
DockPanel.Dock="Top"
|
SelectedItem="{Binding SelectedGroupItem}"
|
||||||
Orientation="Horizontal">
|
Width="200" Margin="0,0,10,0">
|
||||||
<TextBlock Text="Combobox ->"/>
|
|
||||||
<ComboBox ItemsSource="{Binding Groups}" SelectedValue="{Binding SelectedGroupItem}">
|
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Name}"/>
|
<TextBlock Text="{Binding GroupName}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
<Button Width="100" Command="{Binding OpenFileDialog}"/>
|
|
||||||
<ComboBox/>
|
<TextBlock Text="Sort:" VerticalAlignment="Center" Margin="0,0,5,0" />
|
||||||
|
<ComboBox ItemsSource="{Binding SortingOptions}"
|
||||||
|
SelectedItem="{Binding SelectedSortingOption}"
|
||||||
|
Width="200" Margin="0,0,10,0" />
|
||||||
|
|
||||||
|
<Button Content="Remove all"
|
||||||
|
Command="{Binding RemoveAllStudentsCommand}"
|
||||||
|
Margin="10,0,0,0" />
|
||||||
|
|
||||||
|
<Button Content="Import students"
|
||||||
|
Command="{Binding ImportStudentsCommand}"
|
||||||
|
Margin="10,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Border>
|
|
||||||
<ListBox Background="Bisque" ItemsSource="{Binding Users}">
|
<Border BorderBrush="Gray" BorderThickness="1" Margin="10" CornerRadius="5">
|
||||||
|
<ListBox ItemsSource="{Binding Students}"
|
||||||
|
SelectionMode="Multiple"
|
||||||
|
SelectedItems="{Binding SelectedStudents}"
|
||||||
|
SelectionChanged="SelectingItemsControl_OnSelectionChanged"
|
||||||
|
BorderThickness="0">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal" Margin="5">
|
||||||
<TextBlock Text="{Binding Name}" />
|
<TextBlock Text="{Binding FirstName}" FontWeight="Bold" Margin="0,0,10,0" />
|
||||||
|
<TextBlock Text="{Binding LastName}" FontWeight="Bold" Margin="0,0,10,0" />
|
||||||
|
<TextBlock Text="{Binding Patronymic}" FontWeight="Bold" Margin="0,0,10,0" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
|
|
||||||
|
<ListBox.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem Header="Delete selected students"
|
||||||
|
Command="{Binding RemoveSelectedStudentsCommand}"
|
||||||
|
IsVisible="{Binding IsMultipleSelection}"
|
||||||
|
/>
|
||||||
|
<MenuItem Header="Remove"
|
||||||
|
Command="{Binding RemoveSelectedStudentsCommand}"
|
||||||
|
IsVisible="{Binding IsSingleSelection}"
|
||||||
|
/>
|
||||||
|
<MenuItem Header="Edit"
|
||||||
|
IsVisible="{Binding IsSingleSelection}"/>
|
||||||
|
</ContextMenu>
|
||||||
|
</ListBox.ContextMenu>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
</Border>
|
</Border>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</UserControl>
|
</Window>
|
||||||
|
@ -10,28 +10,19 @@ using ReactiveUI;
|
|||||||
|
|
||||||
namespace Presence.Desktop.Views
|
namespace Presence.Desktop.Views
|
||||||
{
|
{
|
||||||
public partial class GroupView : ReactiveUserControl<GroupViewModel>
|
public partial class GroupView : Window
|
||||||
{
|
{
|
||||||
public GroupView()
|
public GroupView()
|
||||||
{
|
{
|
||||||
this.WhenActivated(action =>
|
InitializeComponent();
|
||||||
{
|
|
||||||
action(ViewModel!.SelectFileInteraction.RegisterHandler(ShowFileDialog));
|
|
||||||
});
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ShowFileDialog(IInteractionContext<string?, string?> context)
|
private void SelectingItemsControl_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var topLevel = TopLevel.GetTopLevel(this);
|
if (DataContext is GroupViewModel viewModel)
|
||||||
var storageFile = await topLevel.StorageProvider.OpenFilePickerAsync(
|
{
|
||||||
new FilePickerOpenOptions()
|
viewModel.UpdateSelectionStates();
|
||||||
{
|
}
|
||||||
AllowMultiple = false,
|
|
||||||
Title = context.Input
|
|
||||||
}
|
|
||||||
);
|
|
||||||
context.SetOutput(storageFile.First().Path.ToString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +0,0 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:app="clr-namespace:Presence.Desktop"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:vm="using:Presence.Desktop.ViewModels"
|
|
||||||
xmlns:reactiveUi="http://reactiveui.net"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
|
||||||
x:Class="Presence.Desktop.Views.MainWindow"
|
|
||||||
x:DataType="vm:MainWindowViewModel"
|
|
||||||
Title="MainWindow">
|
|
||||||
<DockPanel>
|
|
||||||
<reactiveUi:RoutedViewHost Router="{Binding Router}" DockPanel.Dock="Right" Background="AliceBlue">
|
|
||||||
<reactiveUi:RoutedViewHost.ViewLocator>
|
|
||||||
<app:ViewLocator/>
|
|
||||||
</reactiveUi:RoutedViewHost.ViewLocator>
|
|
||||||
</reactiveUi:RoutedViewHost>
|
|
||||||
</DockPanel>
|
|
||||||
</Window>
|
|
@ -1,18 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
|
||||||
using Presence.Desktop.ViewModels;
|
|
||||||
using ReactiveUI;
|
|
||||||
|
|
||||||
namespace Presence.Desktop.Views;
|
|
||||||
|
|
||||||
public partial class MainWindow : ReactiveWindow<MainWindowViewModel>
|
|
||||||
{
|
|
||||||
public MainWindow()
|
|
||||||
{
|
|
||||||
this.WhenActivated(disposables => { });
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,320 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using data;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace data.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(RemoteDatabaseContext))]
|
|
||||||
[Migration("20241212071056_InitialCreate123")]
|
|
||||||
partial class InitialCreate123
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Attendance", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("AttendanceId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("AttendanceId"));
|
|
||||||
|
|
||||||
b.Property<DateOnly>("Date")
|
|
||||||
.HasColumnType("date");
|
|
||||||
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("GroupSubjectId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("LessonNumber")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("StudentId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("VisitId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("AttendanceId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupSubjectId");
|
|
||||||
|
|
||||||
b.HasIndex("StudentId");
|
|
||||||
|
|
||||||
b.HasIndex("VisitId");
|
|
||||||
|
|
||||||
b.ToTable("Attendances");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Group", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("GroupId"));
|
|
||||||
|
|
||||||
b.Property<string>("GroupName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("GroupId");
|
|
||||||
|
|
||||||
b.ToTable("Groups");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.GroupSubject", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("GroupSubjectId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("GroupSubjectId"));
|
|
||||||
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("SemesterId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("SubjectId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("GroupSubjectId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupId");
|
|
||||||
|
|
||||||
b.HasIndex("SemesterId");
|
|
||||||
|
|
||||||
b.HasIndex("SubjectId");
|
|
||||||
|
|
||||||
b.ToTable("GroupSubjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Semester", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("SemesterId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SemesterId"));
|
|
||||||
|
|
||||||
b.Property<DateTime>("EndTime")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime>("StartTime")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("SemesterId");
|
|
||||||
|
|
||||||
b.ToTable("Semesters");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Student", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("StudentId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("StudentId"));
|
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Patronymic")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("StudentId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupId");
|
|
||||||
|
|
||||||
b.ToTable("Students");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Subject", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("SubjectId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SubjectId"));
|
|
||||||
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("SubjectId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupId");
|
|
||||||
|
|
||||||
b.ToTable("Subjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Visit", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("VisitId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("VisitId"));
|
|
||||||
|
|
||||||
b.Property<string>("VisitName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("VisitId");
|
|
||||||
|
|
||||||
b.ToTable("Visits");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Attendance", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Data.DAO.Group", "Group")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("GroupId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.GroupSubject", "GroupSubject")
|
|
||||||
.WithMany("Attendances")
|
|
||||||
.HasForeignKey("GroupSubjectId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.Student", "Student")
|
|
||||||
.WithMany("Attendances")
|
|
||||||
.HasForeignKey("StudentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.Visit", "Visit")
|
|
||||||
.WithMany("Attendances")
|
|
||||||
.HasForeignKey("VisitId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Group");
|
|
||||||
|
|
||||||
b.Navigation("GroupSubject");
|
|
||||||
|
|
||||||
b.Navigation("Student");
|
|
||||||
|
|
||||||
b.Navigation("Visit");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.GroupSubject", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Data.DAO.Group", "Group")
|
|
||||||
.WithMany("GroupSubjects")
|
|
||||||
.HasForeignKey("GroupId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.Semester", "Semester")
|
|
||||||
.WithMany("GroupSubjects")
|
|
||||||
.HasForeignKey("SemesterId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.Subject", "Subject")
|
|
||||||
.WithMany("GroupSubjects")
|
|
||||||
.HasForeignKey("SubjectId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Group");
|
|
||||||
|
|
||||||
b.Navigation("Semester");
|
|
||||||
|
|
||||||
b.Navigation("Subject");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Student", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Data.DAO.Group", "Group")
|
|
||||||
.WithMany("Students")
|
|
||||||
.HasForeignKey("GroupId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Group");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Subject", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Data.DAO.Group", "Group")
|
|
||||||
.WithMany("Subjects")
|
|
||||||
.HasForeignKey("GroupId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Group");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Group", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("GroupSubjects");
|
|
||||||
|
|
||||||
b.Navigation("Students");
|
|
||||||
|
|
||||||
b.Navigation("Subjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.GroupSubject", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Attendances");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Semester", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("GroupSubjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Student", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Attendances");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Subject", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("GroupSubjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Visit", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Attendances");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,243 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace data.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate123 : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Groups",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
GroupName = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Groups", x => x.GroupId);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Semesters",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
SemesterId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
StartTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
||||||
EndTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Semesters", x => x.SemesterId);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Visits",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
VisitId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
VisitName = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Visits", x => x.VisitId);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Students",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
StudentId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
FirstName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
LastName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Patronymic = table.Column<string>(type: "text", nullable: false),
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Students", x => x.StudentId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Students_Groups_GroupId",
|
|
||||||
column: x => x.GroupId,
|
|
||||||
principalTable: "Groups",
|
|
||||||
principalColumn: "GroupId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Subjects",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
SubjectId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
SubjectName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Subjects", x => x.SubjectId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Subjects_Groups_GroupId",
|
|
||||||
column: x => x.GroupId,
|
|
||||||
principalTable: "Groups",
|
|
||||||
principalColumn: "GroupId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "GroupSubjects",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
GroupSubjectId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
SemesterId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SubjectId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_GroupSubjects", x => x.GroupSubjectId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_GroupSubjects_Groups_GroupId",
|
|
||||||
column: x => x.GroupId,
|
|
||||||
principalTable: "Groups",
|
|
||||||
principalColumn: "GroupId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_GroupSubjects_Semesters_SemesterId",
|
|
||||||
column: x => x.SemesterId,
|
|
||||||
principalTable: "Semesters",
|
|
||||||
principalColumn: "SemesterId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_GroupSubjects_Subjects_SubjectId",
|
|
||||||
column: x => x.SubjectId,
|
|
||||||
principalTable: "Subjects",
|
|
||||||
principalColumn: "SubjectId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Attendances",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
AttendanceId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Date = table.Column<DateOnly>(type: "date", nullable: false),
|
|
||||||
GroupSubjectId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
StudentId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
VisitId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
LessonNumber = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Attendances", x => x.AttendanceId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Attendances_GroupSubjects_GroupSubjectId",
|
|
||||||
column: x => x.GroupSubjectId,
|
|
||||||
principalTable: "GroupSubjects",
|
|
||||||
principalColumn: "GroupSubjectId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Attendances_Groups_GroupId",
|
|
||||||
column: x => x.GroupId,
|
|
||||||
principalTable: "Groups",
|
|
||||||
principalColumn: "GroupId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Attendances_Students_StudentId",
|
|
||||||
column: x => x.StudentId,
|
|
||||||
principalTable: "Students",
|
|
||||||
principalColumn: "StudentId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Attendances_Visits_VisitId",
|
|
||||||
column: x => x.VisitId,
|
|
||||||
principalTable: "Visits",
|
|
||||||
principalColumn: "VisitId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Attendances_GroupId",
|
|
||||||
table: "Attendances",
|
|
||||||
column: "GroupId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Attendances_GroupSubjectId",
|
|
||||||
table: "Attendances",
|
|
||||||
column: "GroupSubjectId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Attendances_StudentId",
|
|
||||||
table: "Attendances",
|
|
||||||
column: "StudentId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Attendances_VisitId",
|
|
||||||
table: "Attendances",
|
|
||||||
column: "VisitId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_GroupSubjects_GroupId",
|
|
||||||
table: "GroupSubjects",
|
|
||||||
column: "GroupId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_GroupSubjects_SemesterId",
|
|
||||||
table: "GroupSubjects",
|
|
||||||
column: "SemesterId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_GroupSubjects_SubjectId",
|
|
||||||
table: "GroupSubjects",
|
|
||||||
column: "SubjectId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Students_GroupId",
|
|
||||||
table: "Students",
|
|
||||||
column: "GroupId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Subjects_GroupId",
|
|
||||||
table: "Subjects",
|
|
||||||
column: "GroupId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Attendances");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "GroupSubjects");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Students");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Visits");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Semesters");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Subjects");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Groups");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,320 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using data;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace data.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(RemoteDatabaseContext))]
|
|
||||||
[Migration("20241212071851_InitialCreate2")]
|
|
||||||
partial class InitialCreate2
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Attendance", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("AttendanceId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("AttendanceId"));
|
|
||||||
|
|
||||||
b.Property<DateOnly>("Date")
|
|
||||||
.HasColumnType("date");
|
|
||||||
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("GroupSubjectId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("LessonNumber")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("StudentId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("VisitId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("AttendanceId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupSubjectId");
|
|
||||||
|
|
||||||
b.HasIndex("StudentId");
|
|
||||||
|
|
||||||
b.HasIndex("VisitId");
|
|
||||||
|
|
||||||
b.ToTable("Attendances");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Group", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("GroupId"));
|
|
||||||
|
|
||||||
b.Property<string>("GroupName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("GroupId");
|
|
||||||
|
|
||||||
b.ToTable("Groups");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.GroupSubject", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("GroupSubjectId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("GroupSubjectId"));
|
|
||||||
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("SemesterId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("SubjectId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("GroupSubjectId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupId");
|
|
||||||
|
|
||||||
b.HasIndex("SemesterId");
|
|
||||||
|
|
||||||
b.HasIndex("SubjectId");
|
|
||||||
|
|
||||||
b.ToTable("GroupSubjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Semester", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("SemesterId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SemesterId"));
|
|
||||||
|
|
||||||
b.Property<DateTime>("EndTime")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<DateTime>("StartTime")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("SemesterId");
|
|
||||||
|
|
||||||
b.ToTable("Semesters");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Student", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("StudentId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("StudentId"));
|
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Patronymic")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("StudentId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupId");
|
|
||||||
|
|
||||||
b.ToTable("Students");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Subject", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("SubjectId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SubjectId"));
|
|
||||||
|
|
||||||
b.Property<int>("GroupId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("SubjectId");
|
|
||||||
|
|
||||||
b.HasIndex("GroupId");
|
|
||||||
|
|
||||||
b.ToTable("Subjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Visit", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("VisitId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("VisitId"));
|
|
||||||
|
|
||||||
b.Property<string>("VisitName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("VisitId");
|
|
||||||
|
|
||||||
b.ToTable("Visits");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Attendance", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Data.DAO.Group", "Group")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("GroupId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.GroupSubject", "GroupSubject")
|
|
||||||
.WithMany("Attendances")
|
|
||||||
.HasForeignKey("GroupSubjectId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.Student", "Student")
|
|
||||||
.WithMany("Attendances")
|
|
||||||
.HasForeignKey("StudentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.Visit", "Visit")
|
|
||||||
.WithMany("Attendances")
|
|
||||||
.HasForeignKey("VisitId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Group");
|
|
||||||
|
|
||||||
b.Navigation("GroupSubject");
|
|
||||||
|
|
||||||
b.Navigation("Student");
|
|
||||||
|
|
||||||
b.Navigation("Visit");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.GroupSubject", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Data.DAO.Group", "Group")
|
|
||||||
.WithMany("GroupSubjects")
|
|
||||||
.HasForeignKey("GroupId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.Semester", "Semester")
|
|
||||||
.WithMany("GroupSubjects")
|
|
||||||
.HasForeignKey("SemesterId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Data.DAO.Subject", "Subject")
|
|
||||||
.WithMany("GroupSubjects")
|
|
||||||
.HasForeignKey("SubjectId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Group");
|
|
||||||
|
|
||||||
b.Navigation("Semester");
|
|
||||||
|
|
||||||
b.Navigation("Subject");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Student", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Data.DAO.Group", "Group")
|
|
||||||
.WithMany("Students")
|
|
||||||
.HasForeignKey("GroupId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Group");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Subject", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Data.DAO.Group", "Group")
|
|
||||||
.WithMany("Subjects")
|
|
||||||
.HasForeignKey("GroupId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Group");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Group", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("GroupSubjects");
|
|
||||||
|
|
||||||
b.Navigation("Students");
|
|
||||||
|
|
||||||
b.Navigation("Subjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.GroupSubject", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Attendances");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Semester", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("GroupSubjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Student", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Attendances");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Subject", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("GroupSubjects");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Data.DAO.Visit", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Attendances");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,243 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace data.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate2 : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Groups",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
GroupName = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Groups", x => x.GroupId);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Semesters",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
SemesterId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
StartTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
||||||
EndTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Semesters", x => x.SemesterId);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Visits",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
VisitId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
VisitName = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Visits", x => x.VisitId);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Students",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
StudentId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
FirstName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
LastName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Patronymic = table.Column<string>(type: "text", nullable: false),
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Students", x => x.StudentId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Students_Groups_GroupId",
|
|
||||||
column: x => x.GroupId,
|
|
||||||
principalTable: "Groups",
|
|
||||||
principalColumn: "GroupId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Subjects",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
SubjectId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
SubjectName = table.Column<string>(type: "text", nullable: false),
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Subjects", x => x.SubjectId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Subjects_Groups_GroupId",
|
|
||||||
column: x => x.GroupId,
|
|
||||||
principalTable: "Groups",
|
|
||||||
principalColumn: "GroupId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "GroupSubjects",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
GroupSubjectId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
SemesterId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SubjectId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_GroupSubjects", x => x.GroupSubjectId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_GroupSubjects_Groups_GroupId",
|
|
||||||
column: x => x.GroupId,
|
|
||||||
principalTable: "Groups",
|
|
||||||
principalColumn: "GroupId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_GroupSubjects_Semesters_SemesterId",
|
|
||||||
column: x => x.SemesterId,
|
|
||||||
principalTable: "Semesters",
|
|
||||||
principalColumn: "SemesterId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_GroupSubjects_Subjects_SubjectId",
|
|
||||||
column: x => x.SubjectId,
|
|
||||||
principalTable: "Subjects",
|
|
||||||
principalColumn: "SubjectId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Attendances",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
AttendanceId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Date = table.Column<DateOnly>(type: "date", nullable: false),
|
|
||||||
GroupSubjectId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
StudentId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
GroupId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
VisitId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
LessonNumber = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Attendances", x => x.AttendanceId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Attendances_GroupSubjects_GroupSubjectId",
|
|
||||||
column: x => x.GroupSubjectId,
|
|
||||||
principalTable: "GroupSubjects",
|
|
||||||
principalColumn: "GroupSubjectId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Attendances_Groups_GroupId",
|
|
||||||
column: x => x.GroupId,
|
|
||||||
principalTable: "Groups",
|
|
||||||
principalColumn: "GroupId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Attendances_Students_StudentId",
|
|
||||||
column: x => x.StudentId,
|
|
||||||
principalTable: "Students",
|
|
||||||
principalColumn: "StudentId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Attendances_Visits_VisitId",
|
|
||||||
column: x => x.VisitId,
|
|
||||||
principalTable: "Visits",
|
|
||||||
principalColumn: "VisitId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Attendances_GroupId",
|
|
||||||
table: "Attendances",
|
|
||||||
column: "GroupId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Attendances_GroupSubjectId",
|
|
||||||
table: "Attendances",
|
|
||||||
column: "GroupSubjectId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Attendances_StudentId",
|
|
||||||
table: "Attendances",
|
|
||||||
column: "StudentId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Attendances_VisitId",
|
|
||||||
table: "Attendances",
|
|
||||||
column: "VisitId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_GroupSubjects_GroupId",
|
|
||||||
table: "GroupSubjects",
|
|
||||||
column: "GroupId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_GroupSubjects_SemesterId",
|
|
||||||
table: "GroupSubjects",
|
|
||||||
column: "SemesterId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_GroupSubjects_SubjectId",
|
|
||||||
table: "GroupSubjects",
|
|
||||||
column: "SubjectId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Students_GroupId",
|
|
||||||
table: "Students",
|
|
||||||
column: "GroupId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Subjects_GroupId",
|
|
||||||
table: "Subjects",
|
|
||||||
column: "GroupId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Attendances");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "GroupSubjects");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Students");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Visits");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Semesters");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Subjects");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Groups");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,8 +12,8 @@ using data;
|
|||||||
namespace data.Migrations
|
namespace data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(RemoteDatabaseContext))]
|
[DbContext(typeof(RemoteDatabaseContext))]
|
||||||
[Migration("20241212072022_InitialCreate2")]
|
[Migration("20241212072957_WorkWithData")]
|
||||||
partial class InitialCreate2
|
partial class WorkWithData
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace data.Migrations
|
namespace data.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class InitialCreate2 : Migration
|
public partial class WorkWithData : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
@ -6,11 +6,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="Migrations\**" />
|
|
||||||
<EmbeddedResource Remove="Migrations\**" />
|
|
||||||
<None Remove="Migrations\**" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
||||||
|
@ -3,14 +3,17 @@ 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 Domain.Entity;
|
||||||
|
|
||||||
namespace domain.Entity
|
namespace domain.Entity
|
||||||
{
|
{
|
||||||
public class GroupEntity
|
public class GroupEntity
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int GroupId { get; set; }
|
||||||
public string Name { get; set; }
|
public string GroupName { get; set; }
|
||||||
public List<UserEntity> Users { get; set; } = null;
|
|
||||||
|
public IEnumerable<StudentEntity>? Students { get; set; } = null;
|
||||||
|
public List<SubjectEntity> Subjects { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
domain/Entity/StudentEntity.cs
Normal file
19
domain/Entity/StudentEntity.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using domain.Entity;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Domain.Entity
|
||||||
|
{
|
||||||
|
public class StudentEntity
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public string Patronymic { get; set; }
|
||||||
|
|
||||||
|
public GroupEntity Group { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
domain/Entity/SubjectEntity.cs
Normal file
18
domain/Entity/SubjectEntity.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using domain.Entity;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Domain.Entity
|
||||||
|
{
|
||||||
|
public class SubjectEntity
|
||||||
|
{
|
||||||
|
public int SubjectId { get; set; }
|
||||||
|
public string SubjectName { get; set; }
|
||||||
|
|
||||||
|
public int GroupId { get; set; }
|
||||||
|
public GroupEntity Group { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace domain.Entity
|
|
||||||
{
|
|
||||||
public class UserEntity
|
|
||||||
{
|
|
||||||
public Guid Guid { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public GroupEntity Group { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,6 +8,8 @@ namespace domain.Request
|
|||||||
{
|
{
|
||||||
public class AddStudentRequest
|
public class AddStudentRequest
|
||||||
{
|
{
|
||||||
public string StudentName { get; set; }
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public string Patronymic { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
domain/Request/AddSubjectRequest.cs
Normal file
13
domain/Request/AddSubjectRequest.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Domain.Request
|
||||||
|
{
|
||||||
|
public class AddSubjectRequest
|
||||||
|
{
|
||||||
|
public string SubjectName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
domain/Request/AttendanceRequest.cs
Normal file
17
domain/Request/AttendanceRequest.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Domain.Request
|
||||||
|
{
|
||||||
|
public class AttendanceRequest
|
||||||
|
{
|
||||||
|
public DateOnly Date { get; set; }
|
||||||
|
public string Subject { get; set; }
|
||||||
|
public int LessonNumber { get; set; }
|
||||||
|
public int StudentId { get; set; }
|
||||||
|
public int TypeAttendance { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
domain/Request/AttendanceUpdateRequest.cs
Normal file
17
domain/Request/AttendanceUpdateRequest.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Domain.Request
|
||||||
|
{
|
||||||
|
public class AttendanceUpdateRequest
|
||||||
|
{
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
public int LessonNumber { get; set; }
|
||||||
|
public int StudentId { get; set; }
|
||||||
|
public int NewTypeAttendance { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,79 +1,207 @@
|
|||||||
using data.DAO;
|
using data.Repository;
|
||||||
using data.Repository;
|
using Data.DAO;
|
||||||
using domain.Entity;
|
using domain.Entity;
|
||||||
using domain.Request;
|
using domain.Request;
|
||||||
using domain.UseCase;
|
using domain.UseCase;
|
||||||
using System;
|
using Domain.Entity;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace domain.Service
|
namespace domain.Service
|
||||||
{
|
{
|
||||||
public class GroupService : IGroupUseCase
|
public class GroupService : IGroupUseCase
|
||||||
{
|
{
|
||||||
private readonly IGroupRepository _groupRepository;
|
private readonly IGroupRepository _groupRepository;
|
||||||
public GroupService(IGroupRepository groupRepository)
|
|
||||||
|
|
||||||
|
public GroupService(IGroupRepository repositoryGroup)
|
||||||
{
|
{
|
||||||
_groupRepository = groupRepository;
|
_groupRepository = repositoryGroup;
|
||||||
}
|
|
||||||
public void AddGroup(AddGroupRequest addGroupRequest)
|
|
||||||
{
|
|
||||||
_groupRepository.addGroup(new data.DAO.GroupDAO { Name = addGroupRequest.Name });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddGroupWithStudents(AddGroupWithStudentsRequest addGroupWithStudents)
|
|
||||||
|
public void AddGroup(AddGroupRequest addGroupRequest)
|
||||||
{
|
{
|
||||||
GroupDAO groupDAO = new GroupDAO() { Name = addGroupWithStudents.addGroupRequest.Name };
|
_groupRepository.AddGroup(new Group { GroupName = addGroupRequest.Name });
|
||||||
List<UserDAO> users = addGroupWithStudents.addStudentRequests
|
}
|
||||||
.Select(it => new UserDAO { Name = it.StudentName })
|
|
||||||
|
public void AddGroupWithStudents(AddGroupWithStudentsRequest addGroupWithStudent)
|
||||||
|
{
|
||||||
|
Group groups = new Group { GroupName = addGroupWithStudent.addGroupRequest.Name };
|
||||||
|
|
||||||
|
List<Student> students = addGroupWithStudent
|
||||||
|
.addStudentRequests
|
||||||
|
.Select(it => new Student
|
||||||
|
{
|
||||||
|
FirstName = it.FirstName,
|
||||||
|
LastName = it.LastName,
|
||||||
|
Patronymic = it.Patronymic
|
||||||
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
_groupRepository.addGroupWithStudents(groupDAO, users);
|
_groupRepository.addGroupWithStudent(groups, students);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddStudentsToGroup(int groupId, List<AddStudentRequest> students)
|
||||||
|
{
|
||||||
|
var group = _groupRepository.GetGroupById(groupId);
|
||||||
|
if (group == null)
|
||||||
|
{
|
||||||
|
throw new KeyNotFoundException($"Группа с ID {groupId} не найдена.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var studentEntities = students.Select(student => new Student
|
||||||
|
{
|
||||||
|
FirstName = student.FirstName,
|
||||||
|
LastName = student.LastName,
|
||||||
|
Patronymic = student.Patronymic,
|
||||||
|
GroupId = groupId
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
_groupRepository.AddStudentsToGroup(studentEntities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteGroup(int groupId)
|
||||||
|
{
|
||||||
|
_groupRepository.DeleteGroup(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<GroupEntity> GetGroupsWithStudents()
|
public IEnumerable<GroupEntity> GetGroupsWithStudents()
|
||||||
{
|
{
|
||||||
return _groupRepository.getAllGroup().Select(
|
return _groupRepository.GetAllGroup().Select(
|
||||||
group => new GroupEntity()
|
group => new GroupEntity
|
||||||
{
|
{
|
||||||
Id = group.Id,
|
GroupId = group.GroupId,
|
||||||
Name = group.Name,
|
GroupName = group.GroupName,
|
||||||
Users = group.Users.Select(
|
Students = group.Students.Select(
|
||||||
user => new UserEntity
|
user => new StudentEntity
|
||||||
{
|
{
|
||||||
Guid = user.Guid,
|
Id = user.StudentId,
|
||||||
Name = user.Name,
|
FirstName = user.FirstName,
|
||||||
|
LastName = user.LastName,
|
||||||
|
Patronymic = user.Patronymic,
|
||||||
Group = new GroupEntity
|
Group = new GroupEntity
|
||||||
{
|
{
|
||||||
Id = group.Id,
|
GroupId = group.GroupId,
|
||||||
Name = group.Name,
|
GroupName = group.GroupName,
|
||||||
}
|
}
|
||||||
}).ToList()
|
}).ToList(),
|
||||||
|
Subjects = group.GroupSubjects.Select(gs => new SubjectEntity
|
||||||
|
{
|
||||||
|
SubjectId = gs.Subject.SubjectId,
|
||||||
|
SubjectName = gs.Subject.SubjectName
|
||||||
|
}).ToList()
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<GroupEntity>> GetGroupsWithStudentsAsync()
|
public List<SubjectEntity> GetSubjectsByGroupId(int groupId)
|
||||||
{
|
{
|
||||||
var result = await _groupRepository.getAllGroupAsync();
|
var group = _groupRepository.GetGroupWithSubjects(groupId);
|
||||||
|
if (group == null)
|
||||||
|
throw new KeyNotFoundException($"Группа с ID {groupId} не найдена.");
|
||||||
|
|
||||||
return result.Select(
|
return group.Subjects.Select(subject => new SubjectEntity
|
||||||
group => new GroupEntity
|
{
|
||||||
{
|
SubjectId = subject.SubjectId,
|
||||||
Id = group.Id,
|
SubjectName = subject.SubjectName
|
||||||
Name = group.Name,
|
}).ToList();
|
||||||
Users = group.Users.Select(
|
}
|
||||||
user => new UserEntity
|
|
||||||
{
|
public Group GetGroupById(int groupId)
|
||||||
Guid = user.Guid,
|
{
|
||||||
Name = user.Name,
|
var group = _groupRepository.GetGroupById(groupId);
|
||||||
Group = new GroupEntity
|
if (group == null)
|
||||||
{
|
{
|
||||||
Id = group.Id,
|
throw new KeyNotFoundException($"Группа с ID {groupId} не найдена.");
|
||||||
Name = group.Name,
|
}
|
||||||
}
|
return group;
|
||||||
}).ToList()
|
}
|
||||||
}).ToList();
|
|
||||||
|
public List<Subject> GetGroupSubjects(int groupId)
|
||||||
|
{
|
||||||
|
var subjects = _groupRepository.GetGroupSubjects(groupId);
|
||||||
|
if (subjects == null || subjects.Count == 0)
|
||||||
|
{
|
||||||
|
throw new KeyNotFoundException($"Предметы для группы с ID {groupId} не найдены.");
|
||||||
|
}
|
||||||
|
return subjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AddSubjectToGroup(int groupId, string subjectName)
|
||||||
|
{
|
||||||
|
var subject = new Subject
|
||||||
|
{
|
||||||
|
SubjectName = subjectName,
|
||||||
|
};
|
||||||
|
|
||||||
|
return _groupRepository.AddSubjectToGroup(groupId, subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void DeleteAllAttendances()
|
||||||
|
{
|
||||||
|
_groupRepository.DeleteAllAttendances();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteAttendancesByGroup(int groupId)
|
||||||
|
{
|
||||||
|
_groupRepository.DeleteAttendancesByGroup(groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void AddAttendance(Attendance attendance)
|
||||||
|
{
|
||||||
|
if (attendance == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(attendance));
|
||||||
|
}
|
||||||
|
|
||||||
|
_groupRepository.AddAttendance(attendance);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Visit GetVisitById(int visitId)
|
||||||
|
{
|
||||||
|
return _groupRepository.GetVisitById(visitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int GetGroupIdBySubjectName(string subjectName)
|
||||||
|
{
|
||||||
|
return _groupRepository.GetGroupIdBySubjectName(subjectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Subject GetSubjectByName(string subjectName)
|
||||||
|
{
|
||||||
|
return _groupRepository.GetSubjectByName(subjectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Attendance> GetAttendances(int groupId, string? subject = null, DateTime? date = null, int? studentId = null)
|
||||||
|
{
|
||||||
|
return _groupRepository.GetAttendances(groupId, subject, date, studentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Attendance GetAttendanceByDateStudentAndLesson(DateTime date, int studentId, int lessonNumber)
|
||||||
|
{
|
||||||
|
return _groupRepository.GetAttendanceByDateStudentAndLesson(date, studentId, lessonNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAttendance(Attendance attendance)
|
||||||
|
{
|
||||||
|
_groupRepository.UpdateAttendance(attendance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveStudentsFromGroup(int groupId)
|
||||||
|
{
|
||||||
|
_groupRepository.RemoveStudentsFromGroup(groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveStudentsFromGroupByIds(int groupId, List<int> studentIds)
|
||||||
|
{
|
||||||
|
var group = _groupRepository.GetGroupById(groupId);
|
||||||
|
if (group == null)
|
||||||
|
{
|
||||||
|
throw new KeyNotFoundException($"Группа с ID {groupId} не найдена.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_groupRepository.RemoveStudentsFromGroupByIds(groupId, studentIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using domain.Entity;
|
using Data.DAO;
|
||||||
|
using domain.Entity;
|
||||||
using domain.Request;
|
using domain.Request;
|
||||||
|
using Domain.Entity;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -11,8 +13,47 @@ namespace domain.UseCase
|
|||||||
public interface IGroupUseCase
|
public interface IGroupUseCase
|
||||||
{
|
{
|
||||||
public IEnumerable<GroupEntity> GetGroupsWithStudents();
|
public IEnumerable<GroupEntity> GetGroupsWithStudents();
|
||||||
public Task<IEnumerable<GroupEntity>> GetGroupsWithStudentsAsync();
|
|
||||||
public void AddGroup(AddGroupRequest addGroupRequest);
|
public void AddGroup(AddGroupRequest addGroupRequest);
|
||||||
public void AddGroupWithStudents(AddGroupWithStudentsRequest addGroupWithStudents);
|
|
||||||
|
public void AddGroupWithStudents(AddGroupWithStudentsRequest addGroupWithStudent);
|
||||||
|
|
||||||
|
public void DeleteGroup(int groupId);
|
||||||
|
|
||||||
|
List<SubjectEntity> GetSubjectsByGroupId(int groupId);
|
||||||
|
|
||||||
|
public void AddStudentsToGroup(int groupId, List<AddStudentRequest> students);
|
||||||
|
|
||||||
|
public Group GetGroupById(int groupId);
|
||||||
|
|
||||||
|
List<Subject> GetGroupSubjects(int groupId);
|
||||||
|
|
||||||
|
bool AddSubjectToGroup(int groupId, string subjectName);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void DeleteAllAttendances();
|
||||||
|
public void DeleteAttendancesByGroup(int groupId);
|
||||||
|
|
||||||
|
void AddAttendance(Attendance attendance);
|
||||||
|
|
||||||
|
Visit GetVisitById(int visitId);
|
||||||
|
|
||||||
|
Subject GetSubjectByName(string subjectName);
|
||||||
|
int GetGroupIdBySubjectName(string subjectName);
|
||||||
|
|
||||||
|
public IEnumerable<Attendance> GetAttendances(int groupId, string subject = null, DateTime? date = null, int? studentId = null);
|
||||||
|
|
||||||
|
public Attendance GetAttendanceByDateStudentAndLesson(DateTime date, int studentId, int lessonNumber);
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdateAttendance(Attendance attendance);
|
||||||
|
|
||||||
|
|
||||||
|
void RemoveStudentsFromGroup(int groupId);
|
||||||
|
|
||||||
|
|
||||||
|
void RemoveStudentsFromGroupByIds(int groupId, List<int> studentIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Presence.Api", "Presence.Ap
|
|||||||
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63} = {78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}
|
{78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63} = {78C8AC9B-2B4D-4C71-8469-C6DAE16C9A63}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "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
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Loading…
Reference in New Issue
Block a user