diff --git a/Application/Application.csproj b/Application/Application.csproj
new file mode 100644
index 0000000..2003517
--- /dev/null
+++ b/Application/Application.csproj
@@ -0,0 +1,27 @@
+
+
+
+ net8.0
+ disable
+ enable
+ Winsomnia
+ 1.0.0-a0
+ 1.0.0.0
+ 1.0.0.0
+ Mirea.Api.DataAccess.Application
+ $(AssemblyName)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Application/Common/Behaviors/ValidationBehavior.cs b/Application/Common/Behaviors/ValidationBehavior.cs
new file mode 100644
index 0000000..6cd5946
--- /dev/null
+++ b/Application/Common/Behaviors/ValidationBehavior.cs
@@ -0,0 +1,30 @@
+using FluentValidation;
+using MediatR;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Mirea.Api.DataAccess.Application.Common.Behaviors;
+
+public class ValidationBehavior(IEnumerable> validators)
+ : IPipelineBehavior where TRequest : IRequest
+{
+ public Task Handle(TRequest request,
+ RequestHandlerDelegate next, CancellationToken cancellationToken)
+ {
+ var context = new ValidationContext(request);
+ var failures = validators
+ .Select(v => v.Validate(context))
+ .SelectMany(result => result.Errors)
+ .Where(failure => failure != null)
+ .ToList();
+
+ if (failures.Count != 0)
+ {
+ throw new ValidationException(failures);
+ }
+
+ return next();
+ }
+}
\ No newline at end of file
diff --git a/Application/Common/Mappings/AssemblyMappingProfile.cs b/Application/Common/Mappings/AssemblyMappingProfile.cs
new file mode 100644
index 0000000..68a9e8e
--- /dev/null
+++ b/Application/Common/Mappings/AssemblyMappingProfile.cs
@@ -0,0 +1,28 @@
+using AutoMapper;
+using System;
+using System.Linq;
+using System.Reflection;
+
+namespace Mirea.Api.DataAccess.Application.Common.Mappings;
+
+public class AssemblyMappingProfile : Profile
+{
+ public AssemblyMappingProfile(Assembly assembly) =>
+ ApplyMappingsFromAssembly(assembly);
+
+ private void ApplyMappingsFromAssembly(Assembly assembly)
+ {
+ var types = assembly.GetExportedTypes()
+ .Where(type => type.GetInterfaces()
+ .Any(i => i.IsGenericType &&
+ i.GetGenericTypeDefinition() == typeof(IMapWith<>)))
+ .ToList();
+
+ foreach (var type in types)
+ {
+ var instance = Activator.CreateInstance(type);
+ var methodInfo = type.GetMethod("Mapping");
+ methodInfo?.Invoke(instance, new[] { this });
+ }
+ }
+}
\ No newline at end of file
diff --git a/Application/Common/Mappings/IMapWith.cs b/Application/Common/Mappings/IMapWith.cs
new file mode 100644
index 0000000..390e4e0
--- /dev/null
+++ b/Application/Common/Mappings/IMapWith.cs
@@ -0,0 +1,9 @@
+using AutoMapper;
+
+namespace Mirea.Api.DataAccess.Application.Common.Mappings;
+
+public interface IMapWith
+{
+ void Mapping(Profile profile) =>
+ profile.CreateMap(typeof(T), GetType());
+}
\ No newline at end of file
diff --git a/Application/DependencyInjection.cs b/Application/DependencyInjection.cs
new file mode 100644
index 0000000..61c3eab
--- /dev/null
+++ b/Application/DependencyInjection.cs
@@ -0,0 +1,19 @@
+using FluentValidation;
+using MediatR;
+using Microsoft.Extensions.DependencyInjection;
+using Mirea.Api.DataAccess.Application.Common.Behaviors;
+using System.Reflection;
+
+namespace Mirea.Api.DataAccess.Application;
+
+public static class DependencyInjection
+{
+ public static IServiceCollection AddApplication(this IServiceCollection services)
+ {
+ services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
+ services.AddValidatorsFromAssemblies(new[] { Assembly.GetExecutingAssembly() });
+ services.AddTransient(typeof(IPipelineBehavior<,>),
+ typeof(ValidationBehavior<,>));
+ return services;
+ }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/IDbContextBase.cs b/Application/Interfaces/DbContexts/IDbContextBase.cs
new file mode 100644
index 0000000..c06bb69
--- /dev/null
+++ b/Application/Interfaces/DbContexts/IDbContextBase.cs
@@ -0,0 +1,9 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts;
+
+public interface IDbContextBase
+{
+ Task SaveChangesAsync(CancellationToken cancellationToken);
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/ICampusDbContext.cs b/Application/Interfaces/DbContexts/Schedule/ICampusDbContext.cs
new file mode 100644
index 0000000..40cd23b
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/ICampusDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface ICampusDbContext : IDbContextBase
+{
+ DbSet Campuses { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/IDayDbContext.cs b/Application/Interfaces/DbContexts/Schedule/IDayDbContext.cs
new file mode 100644
index 0000000..f34d77a
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/IDayDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface IDayDbContext : IDbContextBase
+{
+ DbSet Days { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/IFacultyDbContext.cs b/Application/Interfaces/DbContexts/Schedule/IFacultyDbContext.cs
new file mode 100644
index 0000000..166c5cc
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/IFacultyDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface IFacultyDbContext : IDbContextBase
+{
+ DbSet Faculties { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/IGroupDbContext.cs b/Application/Interfaces/DbContexts/Schedule/IGroupDbContext.cs
new file mode 100644
index 0000000..1fb85d7
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/IGroupDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface IGroupDbContext : IDbContextBase
+{
+ DbSet Groups { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/ILectureHallDbContext.cs b/Application/Interfaces/DbContexts/Schedule/ILectureHallDbContext.cs
new file mode 100644
index 0000000..04f1a37
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/ILectureHallDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface ILectureHallDbContext : IDbContextBase
+{
+ DbSet LectureHalls { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/ILessonDbContext.cs b/Application/Interfaces/DbContexts/Schedule/ILessonDbContext.cs
new file mode 100644
index 0000000..b29561a
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/ILessonDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface ILessonDbContext : IDbContextBase
+{
+ DbSet Lessons { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/ILessonToTypeOfOccupationDbContext.cs b/Application/Interfaces/DbContexts/Schedule/ILessonToTypeOfOccupationDbContext.cs
new file mode 100644
index 0000000..0dacc7e
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/ILessonToTypeOfOccupationDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface ILessonToTypeOfOccupationDbContext : IDbContextBase
+{
+ DbSet LessonToTypeOfOccupations { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/IProfessorDbContext.cs b/Application/Interfaces/DbContexts/Schedule/IProfessorDbContext.cs
new file mode 100644
index 0000000..bb4b0d7
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/IProfessorDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface IProfessorDbContext : IDbContextBase
+{
+ DbSet Professors { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/IProfessorToLessonDbContext.cs b/Application/Interfaces/DbContexts/Schedule/IProfessorToLessonDbContext.cs
new file mode 100644
index 0000000..ba6aba5
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/IProfessorToLessonDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface IProfessorToLessonDbContext : IDbContextBase
+{
+ DbSet ProfessorToLessons { get; set; }
+}
\ No newline at end of file
diff --git a/Application/Interfaces/DbContexts/Schedule/ITypeOfOccupationDbContext.cs b/Application/Interfaces/DbContexts/Schedule/ITypeOfOccupationDbContext.cs
new file mode 100644
index 0000000..0c18dfa
--- /dev/null
+++ b/Application/Interfaces/DbContexts/Schedule/ITypeOfOccupationDbContext.cs
@@ -0,0 +1,9 @@
+using Microsoft.EntityFrameworkCore;
+using Mirea.Api.DataAccess.Domain.Schedule;
+
+namespace Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
+
+public interface ITypeOfOccupationDbContext : IDbContextBase
+{
+ DbSet TypeOfOccupations { get; set; }
+}
\ No newline at end of file
diff --git a/Backend.sln b/Backend.sln
index 5c85ec6..f78e7d8 100644
--- a/Backend.sln
+++ b/Backend.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{C27FB5CD-6A70-4FB2-847A-847B34806902}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "Domain\Domain.csproj", "{C27FB5CD-6A70-4FB2-847A-847B34806902}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Endpoint", "Endpoint\Endpoint.csproj", "{F3A1D12E-F5B2-4339-9966-DBF869E78357}"
EndProject
@@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution",
README.md = README.md
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application", "Application\Application.csproj", "{E7F0A4D4-B032-4BB9-9526-1AF688F341A4}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU