оплата у психолога не прошла, продолжаем делать
This commit is contained in:
parent
755acc02a9
commit
4a9bd06926
@ -7,9 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "University", "University\Un
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDataModels", "UniversityDataModels\UniversityDataModels.csproj", "{213B879D-95E6-4554-8C05-DF591E9006FF}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDataModels", "UniversityDataModels\UniversityDataModels.csproj", "{213B879D-95E6-4554-8C05-DF591E9006FF}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityContracts", "UniversityContracts\UniversityContracts.csproj", "{AC1D090C-E5C5-412C-88F7-139A64F6C58C}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityContracts", "UniversityContracts\UniversityContracts.csproj", "{AC1D090C-E5C5-412C-88F7-139A64F6C58C}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityBusinessLogics", "UniversityBusinessLogics\UniversityBusinessLogics.csproj", "{EAB93F1E-4582-493D-8E4A-2EF5C02D20BB}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityBusinessLogics", "UniversityBusinessLogics\UniversityBusinessLogics.csproj", "{EAB93F1E-4582-493D-8E4A-2EF5C02D20BB}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityDatabaseImplement", "UniversityDatabaseImplement\UniversityDatabaseImplement.csproj", "{F0442491-14CD-42ED-B684-4BE30D5A1FEE}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -33,6 +35,10 @@ Global
|
|||||||
{EAB93F1E-4582-493D-8E4A-2EF5C02D20BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EAB93F1E-4582-493D-8E4A-2EF5C02D20BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EAB93F1E-4582-493D-8E4A-2EF5C02D20BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EAB93F1E-4582-493D-8E4A-2EF5C02D20BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{EAB93F1E-4582-493D-8E4A-2EF5C02D20BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EAB93F1E-4582-493D-8E4A-2EF5C02D20BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F0442491-14CD-42ED-B684-4BE30D5A1FEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F0442491-14CD-42ED-B684-4BE30D5A1FEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F0442491-14CD-42ED-B684-4BE30D5A1FEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F0442491-14CD-42ED-B684-4BE30D5A1FEE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -0,0 +1,115 @@
|
|||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace UniversityDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ClientStorage : IClientStorage
|
||||||
|
{
|
||||||
|
private void CheckSearchModel(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
throw new ArgumentNullException("Передаваемая модель для поиска равна нулю", nameof(model));
|
||||||
|
if (!model.Id.HasValue && !model.DirectorId.HasValue && model.DisciplinesIds == null)
|
||||||
|
throw new ArgumentException("Все передаваемые поля поисковой модели оказались пусты или равны null");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
var element = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Clients.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
CheckSearchModel(model);
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
return context.Clients
|
||||||
|
.Include(x => x.Director)
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
CheckSearchModel(model);
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
// Запрос на получения клиентов с счетовами за период производится в сущности счетова,
|
||||||
|
// что позволяет избежать ненужный join или пост обработки запроса
|
||||||
|
|
||||||
|
// Включаем работника для view-model
|
||||||
|
var query = context.Clients.Include(x => x.Director);
|
||||||
|
if (model.DirectorId.HasValue)
|
||||||
|
{
|
||||||
|
// Нет необходимости включать счетову для отчета, поэтому включаем только сотрудника
|
||||||
|
return query
|
||||||
|
.Where(x => model.DirectorId == x.DirectorId)
|
||||||
|
.Select(x => (ClientViewModel)x)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
// Выбираем клиента из списка айдишников дисциплин на посещения
|
||||||
|
if (model.DisciplinesIds != null)
|
||||||
|
return query
|
||||||
|
.Include(x => x.Disciplines)!
|
||||||
|
.ThenInclude(x => x.Discipline)
|
||||||
|
.ThenInclude(x => x.Client)
|
||||||
|
.Where(x => x.Disciplines.Any(y => model.DisciplinesIds.Contains(y.DisciplineId)))
|
||||||
|
.Select(x => (ClientViewModel)x)
|
||||||
|
.ToList();
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
return context.Clients.Include(x => x.Director)
|
||||||
|
.Select(x => (ClientViewModel)x)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
var newClient = Client.Create(model);
|
||||||
|
if (newClient == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
context.Clients.Add(newClient);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
var Client = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (Client == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Client.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return Client;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace UniversityDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class DirectorStorage : IDirectorStorage
|
||||||
|
{
|
||||||
|
private void CheckSearchModel(DirectorSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
throw new ArgumentNullException("Передаваемая модель для поиска равна нулю", nameof(model));
|
||||||
|
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password))
|
||||||
|
throw new ArgumentException("Все передаваемые поля поисковой модели оказались пусты или равны null");
|
||||||
|
}
|
||||||
|
public DirectorViewModel? GetElement(DirectorSearchModel model)
|
||||||
|
{
|
||||||
|
CheckSearchModel(model);
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
// возможность поиска только по логину для проверки на уникальность, или поиска по логина и паролю
|
||||||
|
return context.Directors
|
||||||
|
.FirstOrDefault(x => x.Login.Equals(model.Login) && (string.IsNullOrEmpty(model.Password) || x.Password.Equals(model.Password)));
|
||||||
|
}
|
||||||
|
public DirectorViewModel? Insert(DirectorBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var newDirector = Director.Create(model);
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
context.Directors.Add(newDirector);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newDirector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace UniversityDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class RequirementStorage : IRequirementStorage
|
||||||
|
{
|
||||||
|
private void CheckSearchModel(RequirementSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
throw new ArgumentNullException("Передаваемая модель для поиска равна нулю", nameof(model));
|
||||||
|
if (!model.Id.HasValue && !model.DirectorId.HasValue)
|
||||||
|
throw new ArgumentException("Все передаваемые поля поисковой модели оказались пусты или равны null");
|
||||||
|
}
|
||||||
|
public RequirementViewModel? Delete(RequirementBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
var element = context.Requirements.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Requirements.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequirementViewModel? GetElement(RequirementSearchModel model)
|
||||||
|
{
|
||||||
|
CheckSearchModel(model);
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return context.Requirements
|
||||||
|
.Include(requirement => requirement.Director)
|
||||||
|
.Include(requirement => requirement.Disciplines).ThenInclude(requirementByDiscipline => requirementByDiscipline.Discipline)
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RequirementViewModel> GetFilteredList(RequirementSearchModel model)
|
||||||
|
{
|
||||||
|
CheckSearchModel(model);
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
return context.Requirements
|
||||||
|
.Include(requirement => requirement.Director)
|
||||||
|
.Include(requirement => requirement.Disciplines).ThenInclude(requirementByDiscipline => requirementByDiscipline.Discipline)
|
||||||
|
.Where(x => x.DirectorId == model.DirectorId)
|
||||||
|
.Select(x => (RequirementViewModel)x)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RequirementViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
return context.Requirements
|
||||||
|
.Include(requirement => requirement.Director)
|
||||||
|
.Include(requirement => requirement.Disciplines).ThenInclude(requirementByDiscipline => requirementByDiscipline.Discipline)
|
||||||
|
.Select(x => (RequirementViewModel)x)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequirementViewModel? Insert(RequirementBindingModel model)
|
||||||
|
{
|
||||||
|
var newRequirement = Requirement.Create(model);
|
||||||
|
if (newRequirement == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
// Согласно тз при создании требований не требуется связывать ее с дисциплиными, поэтому нет UpdateDisciplines
|
||||||
|
context.Requirements.Add(newRequirement);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newRequirement;
|
||||||
|
}
|
||||||
|
public RequirementViewModel? Update(RequirementBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new UniversityDB();
|
||||||
|
var requirement = context.Requirements.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (requirement == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
requirement.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
requirement.UpdateDisciplines(context, model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return requirement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\UniversityDataModels\UniversityDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user