Merge pull request 'provider' (#6) from provider into main
Reviewed-on: http://student.git.athene.tech/ker73rus/PIbd-21_Pyatakov_KM_Markov_DP_University/pulls/6
This commit is contained in:
commit
2ecbb0471b
@ -5,8 +5,6 @@ VisualStudioVersion = 17.4.33213.308
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityCustomer", "UniversityCustomer\UniversityCustomer.csproj", "{1360F158-7807-49AD-94A2-4E2ACB2A941E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityCustomer", "UniversityCustomer\UniversityCustomer.csproj", "{1360F158-7807-49AD-94A2-4E2ACB2A941E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityProvider", "UniversityProvider\UniversityProvider.csproj", "{78686252-0C90-4D1C-ADC6-8CFCCB84C393}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityModels", "UniversityModels\UniversityModels.csproj", "{597412F7-884C-49CB-AC41-36308551D330}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityModels", "UniversityModels\UniversityModels.csproj", "{597412F7-884C-49CB-AC41-36308551D330}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDataBaseImplemet", "UniversityDataBaseImplemet\UniversityDataBaseImplemet.csproj", "{F8532F5E-942B-428E-8A10-280E905B8185}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDataBaseImplemet", "UniversityDataBaseImplemet\UniversityDataBaseImplemet.csproj", "{F8532F5E-942B-428E-8A10-280E905B8185}"
|
||||||
@ -15,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityContracts", "Univ
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityBusinessLogic", "UniversityBusinessLogic\UniversityBusinessLogic.csproj", "{1F4D08DA-C856-42E5-8E1A-634B6EDB4C9D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityBusinessLogic", "UniversityBusinessLogic\UniversityBusinessLogic.csproj", "{1F4D08DA-C856-42E5-8E1A-634B6EDB4C9D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityProvider", "UniversityProvider\UniversityProvider.csproj", "{3EC7CE2C-9D59-4570-B66B-746076D00A03}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -25,10 +25,6 @@ Global
|
|||||||
{1360F158-7807-49AD-94A2-4E2ACB2A941E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1360F158-7807-49AD-94A2-4E2ACB2A941E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1360F158-7807-49AD-94A2-4E2ACB2A941E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1360F158-7807-49AD-94A2-4E2ACB2A941E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1360F158-7807-49AD-94A2-4E2ACB2A941E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1360F158-7807-49AD-94A2-4E2ACB2A941E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{78686252-0C90-4D1C-ADC6-8CFCCB84C393}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{78686252-0C90-4D1C-ADC6-8CFCCB84C393}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{78686252-0C90-4D1C-ADC6-8CFCCB84C393}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{78686252-0C90-4D1C-ADC6-8CFCCB84C393}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{597412F7-884C-49CB-AC41-36308551D330}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{597412F7-884C-49CB-AC41-36308551D330}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{597412F7-884C-49CB-AC41-36308551D330}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{597412F7-884C-49CB-AC41-36308551D330}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{597412F7-884C-49CB-AC41-36308551D330}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{597412F7-884C-49CB-AC41-36308551D330}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
@ -45,6 +41,10 @@ Global
|
|||||||
{1F4D08DA-C856-42E5-8E1A-634B6EDB4C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1F4D08DA-C856-42E5-8E1A-634B6EDB4C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1F4D08DA-C856-42E5-8E1A-634B6EDB4C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1F4D08DA-C856-42E5-8E1A-634B6EDB4C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1F4D08DA-C856-42E5-8E1A-634B6EDB4C9D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1F4D08DA-C856-42E5-8E1A-634B6EDB4C9D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3EC7CE2C-9D59-4570-B66B-746076D00A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3EC7CE2C-9D59-4570-B66B-746076D00A03}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3EC7CE2C-9D59-4570-B66B-746076D00A03}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3EC7CE2C-9D59-4570-B66B-746076D00A03}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
97
UniversityBusinessLogic/BusinessLogics/DisciplineLogic.cs
Normal file
97
UniversityBusinessLogic/BusinessLogics/DisciplineLogic.cs
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class DisciplineLogic : IDisciplineLogic
|
||||||
|
{
|
||||||
|
private readonly IDisciplineStorage _disciplineStorage;
|
||||||
|
|
||||||
|
public DisciplineLogic(IDisciplineStorage disciplineStorage)
|
||||||
|
{
|
||||||
|
_disciplineStorage = disciplineStorage;
|
||||||
|
}
|
||||||
|
public bool Create(DisciplineBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_disciplineStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(DisciplineBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_disciplineStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisciplineViewModel? ReadElement(DisciplineSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var discipline = _disciplineStorage.GetElement(model);
|
||||||
|
if (discipline == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return discipline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DisciplineViewModel>? ReadList(DisciplineSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _disciplineStorage.GetFullList() : _disciplineStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(DisciplineBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_disciplineStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void CheckModel(DisciplineBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет Имени", nameof(model.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
var discipline = _disciplineStorage.GetElement(new DisciplineSearchModel { Name = model.Name });
|
||||||
|
if (discipline != null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Дисциплина с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
101
UniversityBusinessLogic/BusinessLogics/DocumentLogic.cs
Normal file
101
UniversityBusinessLogic/BusinessLogics/DocumentLogic.cs
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class DocumentLogic : IDocumentLogic
|
||||||
|
{
|
||||||
|
private readonly IDocumentStorage _documentStorage;
|
||||||
|
|
||||||
|
public DocumentLogic(IDocumentStorage documentStorage)
|
||||||
|
{
|
||||||
|
_documentStorage = documentStorage;
|
||||||
|
}
|
||||||
|
public bool Create(DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if(_documentStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_documentStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_documentStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public DocumentViewModel? ReadElement(DocumentSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var document = _documentStorage.GetElement(model);
|
||||||
|
if (document == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
public List<DocumentViewModel>? ReadList(DocumentSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _documentStorage.GetFullList() : _documentStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(DocumentBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия документа", nameof(model.Name));
|
||||||
|
}
|
||||||
|
if (model.Date > DateTime.Now)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Неверно указана дата", nameof(model.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
var document = _documentStorage.GetElement(new DocumentSearchModel
|
||||||
|
{
|
||||||
|
Name = model.Name,
|
||||||
|
});
|
||||||
|
if (document != null && document.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Приказ с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class EducationGroupLogic
|
||||||
|
{
|
||||||
|
private readonly IEducationGroupStorage _egStorage;
|
||||||
|
|
||||||
|
public EducationGroupLogic(IEducationGroupStorage cardStorage)
|
||||||
|
{
|
||||||
|
_egStorage = cardStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(EducationGroupBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_egStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(EducationGroupBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_egStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(EducationGroupBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_egStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public EducationGroupViewModel? ReadElement(EducationGroupSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var es = _egStorage.GetElement(model);
|
||||||
|
if (es == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return es;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EducationGroupViewModel>? ReadList(EducationGroupSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _egStorage.GetFullList() : _egStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(EducationGroupBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия статуса обучения", nameof(model.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
var es = _egStorage.GetElement(new EducationGroupSearchModel
|
||||||
|
{
|
||||||
|
Name = model.Name,
|
||||||
|
});
|
||||||
|
if (es != null && es.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Статус с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class EducationStatusLogic : IEducationStatusLogic
|
||||||
|
{
|
||||||
|
private readonly IEducationStatusStorage _esStorage;
|
||||||
|
|
||||||
|
public EducationStatusLogic(IEducationStatusStorage cardStorage)
|
||||||
|
{
|
||||||
|
_esStorage = cardStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(EducationStatusBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_esStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(EducationStatusBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_esStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(EducationStatusBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_esStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public EducationStatusViewModel? ReadElement(EducationStatusSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var es = _esStorage.GetElement(model);
|
||||||
|
if (es == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return es;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EducationStatusViewModel>? ReadList(EducationStatusSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _esStorage.GetFullList() : _esStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(EducationStatusBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия статуса обучения", nameof(model.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
var es = _esStorage.GetElement(new EducationStatusSearchModel
|
||||||
|
{
|
||||||
|
Name = model.Name,
|
||||||
|
});
|
||||||
|
if (es != null && es.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Статус с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
110
UniversityBusinessLogic/BusinessLogics/ReportCustomerLogic.cs
Normal file
110
UniversityBusinessLogic/BusinessLogics/ReportCustomerLogic.cs
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityBusinessLogic.OfficePackage;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Net;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ReportCustomerLogic : IReportCustomerLogic
|
||||||
|
{
|
||||||
|
private readonly IDocumentStorage _documentStorage;
|
||||||
|
private readonly IStudentStorage _studentStorage;
|
||||||
|
private readonly IEducationStatusStorage _educationStatusStorage;
|
||||||
|
private readonly IEducationGroupStorage _educationGroupStorage;
|
||||||
|
private readonly IDisciplineStorage _disciplineStorage;
|
||||||
|
private readonly IStreamStorage _streamStorage;
|
||||||
|
private readonly AbstractSaveToExcelProvider _saveToExcel;
|
||||||
|
private readonly AbstractSaveToWordProvider _saveToWord;
|
||||||
|
private readonly AbstractSaveToPdfProvider _saveToPdf;
|
||||||
|
|
||||||
|
public ReportCustomerLogic(IDocumentStorage documentStorage,
|
||||||
|
IStudentStorage studentStorage,
|
||||||
|
IEducationStatusStorage educationStatusStorage,
|
||||||
|
IEducationGroupStorage educationGroupStorage,
|
||||||
|
IDisciplineStorage disciplineStorage,
|
||||||
|
IStreamStorage streamStorage,
|
||||||
|
AbstractSaveToExcelProvider saveToExcel,
|
||||||
|
AbstractSaveToWordProvider saveToWord,
|
||||||
|
AbstractSaveToPdfProvider saveToPdf)
|
||||||
|
{
|
||||||
|
_documentStorage = documentStorage;
|
||||||
|
_studentStorage = studentStorage;
|
||||||
|
_educationStatusStorage = educationStatusStorage;
|
||||||
|
_educationGroupStorage = educationGroupStorage;
|
||||||
|
_disciplineStorage = disciplineStorage;
|
||||||
|
_streamStorage = streamStorage;
|
||||||
|
_saveToExcel = saveToExcel;
|
||||||
|
_saveToWord = saveToWord;
|
||||||
|
_saveToPdf = saveToPdf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ReportDisciplineViewModel> GetDiscipline(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
var result = _streamStorage.GetFilteredList(new StreamSearchModel { Id = _disciplineStorage.GetElement(new DisciplineSearchModel { Name = model.DisciplineName })?.StreamId })
|
||||||
|
.Select(stream => new ReportDisciplineViewModel
|
||||||
|
{
|
||||||
|
DisciplineName = model.DisciplineName,
|
||||||
|
StudentEdStatus = stream.StudentStream
|
||||||
|
.Where(student => _documentStorage.GetFilteredList(new DocumentSearchModel
|
||||||
|
{
|
||||||
|
UserId = model.UserId,
|
||||||
|
DateFrom = model.DateFrom,
|
||||||
|
DateTo = model.DateTo,
|
||||||
|
})
|
||||||
|
.Any(document => document.StudentDocument.ContainsKey(student.Value.Id)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени
|
||||||
|
.Join(_documentStorage.GetFullList(),
|
||||||
|
t1 => t1.Value.Id,
|
||||||
|
t2 => t2.UserId,
|
||||||
|
(t1, t2) => new { student = t1, document = t2 })
|
||||||
|
.Select(res => (
|
||||||
|
StudentFIO: $"{res.student.Value.Name} {res.student.Value.Surname}",
|
||||||
|
Document: $"{res.document.Date}",
|
||||||
|
EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = res.student.Value.EducationStatusId })?.Name ?? "не удалось получить"))
|
||||||
|
.ToList()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public List<ReportStreamEducationStatusViewModel> StreamEducationStatus(List<StreamViewModel> streams)
|
||||||
|
{
|
||||||
|
var result = streams
|
||||||
|
.Select(stream => new ReportStreamEducationStatusViewModel
|
||||||
|
{
|
||||||
|
StreamName = stream.Name,
|
||||||
|
StudentEdStatus = stream.StudentStream
|
||||||
|
.Select(student => (
|
||||||
|
StudentFIO: $"{student.Value.Name} {student.Value.Surname}",
|
||||||
|
EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = student.Value.EducationStatusId })?.Name ?? "не удалось получить"))
|
||||||
|
.ToList()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SaveBlanksToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveDocumentBlankToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
108
UniversityBusinessLogic/BusinessLogics/ReportProviderLogic.cs
Normal file
108
UniversityBusinessLogic/BusinessLogics/ReportProviderLogic.cs
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityBusinessLogic.OfficePackage;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ReportProviderLogic : IReportProviderLogic
|
||||||
|
{
|
||||||
|
private readonly IDocumentStorage _documentStorage;
|
||||||
|
private readonly IStudentStorage _studentStorage;
|
||||||
|
private readonly IEducationStatusStorage _educationStatusStorage;
|
||||||
|
private readonly IEducationGroupStorage _educationGroupStorage;
|
||||||
|
private readonly IDisciplineStorage _disciplineStorage;
|
||||||
|
private readonly IStreamStorage _streamStorage;
|
||||||
|
private readonly AbstractSaveToExcelProvider _saveToExcel;
|
||||||
|
private readonly AbstractSaveToWordProvider _saveToWord;
|
||||||
|
private readonly AbstractSaveToPdfProvider _saveToPdf;
|
||||||
|
|
||||||
|
public ReportProviderLogic(IDocumentStorage documentStorage,
|
||||||
|
IStudentStorage studentStorage,
|
||||||
|
IEducationStatusStorage educationStatusStorage,
|
||||||
|
IEducationGroupStorage educationGroupStorage,
|
||||||
|
IDisciplineStorage disciplineStorage,
|
||||||
|
IStreamStorage streamStorage,
|
||||||
|
AbstractSaveToExcelProvider saveToExcel,
|
||||||
|
AbstractSaveToWordProvider saveToWord,
|
||||||
|
AbstractSaveToPdfProvider saveToPdf)
|
||||||
|
{
|
||||||
|
_documentStorage = documentStorage;
|
||||||
|
_studentStorage = studentStorage;
|
||||||
|
_educationStatusStorage = educationStatusStorage;
|
||||||
|
_educationGroupStorage = educationGroupStorage;
|
||||||
|
_disciplineStorage = disciplineStorage;
|
||||||
|
_streamStorage = streamStorage;
|
||||||
|
_saveToExcel = saveToExcel;
|
||||||
|
_saveToWord = saveToWord;
|
||||||
|
_saveToPdf = saveToPdf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ReportStudentsDisciplineViewModel> GetStudentsDiscipline(List<StudentViewModel> students)
|
||||||
|
{
|
||||||
|
var result = students
|
||||||
|
.Select(student => new ReportStudentsDisciplineViewModel
|
||||||
|
{
|
||||||
|
StudentFIO = $"{student.Name} {student.Surname}",
|
||||||
|
Disciplines = _streamStorage.GetFullList()
|
||||||
|
.Where(stream => stream.StudentStream.ContainsKey(student.Id))
|
||||||
|
.Join(_disciplineStorage.GetFullList(),
|
||||||
|
stream => stream.Id,
|
||||||
|
discipline => discipline.StreamId,
|
||||||
|
(stream, discipline) => discipline.Name)
|
||||||
|
.ToList()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public List<ReportStreamStudentEdStatPeriodViewModel> StreamStudentEdStatPeriod(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
var result = _streamStorage
|
||||||
|
.GetFilteredList(new StreamSearchModel { UserId = model.UserId })
|
||||||
|
.Select(stream => new ReportStreamStudentEdStatPeriodViewModel
|
||||||
|
{
|
||||||
|
StreamName = stream.Name,
|
||||||
|
StudentEdStatus = stream.StudentStream
|
||||||
|
.Where(student => _documentStorage.GetFilteredList(new DocumentSearchModel
|
||||||
|
{
|
||||||
|
UserId = model.UserId,
|
||||||
|
DateFrom = model.DateFrom,
|
||||||
|
DateTo = model.DateTo,
|
||||||
|
})
|
||||||
|
.Any(document => document.StudentDocument.ContainsKey(student.Value.Id)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени
|
||||||
|
.Select(student => (
|
||||||
|
StudentFIO: $"{student.Value.Name} {student.Value.Surname}",
|
||||||
|
EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = student.Value.EducationStatusId })?.Name ?? "не удалось получить"))
|
||||||
|
.ToList()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveBlanksToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveDocumentBlankToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
100
UniversityBusinessLogic/BusinessLogics/RoleLogic.cs
Normal file
100
UniversityBusinessLogic/BusinessLogics/RoleLogic.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class RoleLogic : IRoleLogic
|
||||||
|
{
|
||||||
|
private readonly IRoleStorage _roleStorage;
|
||||||
|
public RoleLogic(IRoleStorage roleStorage)
|
||||||
|
{
|
||||||
|
_roleStorage = roleStorage;
|
||||||
|
}
|
||||||
|
public bool Create(RoleBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_roleStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(RoleBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_roleStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleViewModel? ReadElement(RoleSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var element = _roleStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RoleViewModel>? ReadList(RoleSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _roleStorage.GetFullList() : _roleStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(RoleBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_roleStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(RoleBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия роли", nameof(model.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _roleStorage.GetElement(new RoleSearchModel
|
||||||
|
{
|
||||||
|
Name = model.Name
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Роль с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
90
UniversityBusinessLogic/BusinessLogics/StreamLogic.cs
Normal file
90
UniversityBusinessLogic/BusinessLogics/StreamLogic.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class StreamLogic : IStreamLogic
|
||||||
|
{
|
||||||
|
private readonly IStreamStorage _streamStorage;
|
||||||
|
|
||||||
|
public StreamLogic(IStreamStorage streamStorage)
|
||||||
|
{
|
||||||
|
_streamStorage = streamStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(StreamBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_streamStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(StreamBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_streamStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(StreamBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_streamStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public StreamViewModel? ReadElement(StreamSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var stream = _streamStorage.GetElement(model);
|
||||||
|
if (stream == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StreamViewModel>? ReadList(StreamSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _streamStorage.GetFullList() : _streamStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(StreamBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия потока", nameof(model.Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
103
UniversityBusinessLogic/BusinessLogics/StudentLogic.cs
Normal file
103
UniversityBusinessLogic/BusinessLogics/StudentLogic.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class StudentLogic : IStudentLogic
|
||||||
|
{
|
||||||
|
private readonly IStudentStorage _studentStorage;
|
||||||
|
|
||||||
|
public StudentLogic(IStudentStorage studentStorage)
|
||||||
|
{
|
||||||
|
_studentStorage = studentStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_studentStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_studentStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_studentStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public StudentViewModel? ReadElement(StudentSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var student = _studentStorage.GetElement(model);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return student;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StudentViewModel>? ReadList(StudentSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _studentStorage.GetFullList() : _studentStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(StudentBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия документа", nameof(model.Name));
|
||||||
|
}
|
||||||
|
if (model.StudentCard <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Неверно указан номер студенческого билета", nameof(model.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
var student = _studentStorage.GetElement(new StudentSearchModel
|
||||||
|
{
|
||||||
|
StudentCard = model.StudentCard,
|
||||||
|
});
|
||||||
|
if (student != null && student.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Приказ с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
97
UniversityBusinessLogic/BusinessLogics/UserLogic.cs
Normal file
97
UniversityBusinessLogic/BusinessLogics/UserLogic.cs
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class UserLogic : IUserLogic
|
||||||
|
{
|
||||||
|
private readonly IUserStorage _userStorage;
|
||||||
|
|
||||||
|
public UserLogic(IUserStorage userStorage)
|
||||||
|
{
|
||||||
|
_userStorage = userStorage;
|
||||||
|
}
|
||||||
|
public bool Create(UserBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_userStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(UserBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_userStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserViewModel? ReadElement(UserSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var user = _userStorage.GetElement(model);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserViewModel>? ReadList(UserSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _userStorage.GetFullList() : _userStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(UserBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_userStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void CheckModel(UserBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Login))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет логина", nameof(model.Login));
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = _userStorage.GetElement(new UserSearchModel{Login = model.Login});
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Пользователь с таким логином уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
namespace UniversityBusinessLogic;
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToExcelProvider
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToPdfProvider
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToWordProvider
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -6,4 +6,14 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="OfficePackage\HelperEnums\" />
|
||||||
|
<Folder Include="OfficePackage\HelperModels\" />
|
||||||
|
<Folder Include="OfficePackage\Implements\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
24
UniversityContracts/BindingModels/DisciplineBindingModel.cs
Normal file
24
UniversityContracts/BindingModels/DisciplineBindingModel.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class DisciplineBindingModel: IDisciplineModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Hours { get; set; }
|
||||||
|
|
||||||
|
public bool MarkType { get; set; }
|
||||||
|
|
||||||
|
public int StreamId { get; set; }
|
||||||
|
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
UniversityContracts/BindingModels/DocumentBindingModel.cs
Normal file
18
UniversityContracts/BindingModels/DocumentBindingModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class DocumentBindingModel : IDocumentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public DateTime Date { get; set; } = DateTime.Now;
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public Dictionary<int, IStudentModel> StudentDocument { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class EducationGroupBindingModel : IEducationGroupModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public int NumberOfStudent { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class EducationStatusBindingModel : IEducationStatusModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
17
UniversityContracts/BindingModels/ReportBindingModel.cs
Normal file
17
UniversityContracts/BindingModels/ReportBindingModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ReportBindingModel
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string DisciplineName { get; set; } = string.Empty;
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
UniversityContracts/BindingModels/RoleBindingModel.cs
Normal file
15
UniversityContracts/BindingModels/RoleBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class RoleBindingModel : IRoleModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
22
UniversityContracts/BindingModels/StreamBindingModel.cs
Normal file
22
UniversityContracts/BindingModels/StreamBindingModel.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class StreamBindingModel : IStreamModel
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Course { get; set; }
|
||||||
|
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
public Dictionary<int, IStudentModel> StudentStream { get; set; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
20
UniversityContracts/BindingModels/StudentBindingModel.cs
Normal file
20
UniversityContracts/BindingModels/StudentBindingModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class StudentBindingModel : IStudentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public string Surname { get; set; } = string.Empty;
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
public int StudentCard { get; set; }
|
||||||
|
public int EducationStatusId { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
UniversityContracts/BindingModels/UserBindingModel.cs
Normal file
17
UniversityContracts/BindingModels/UserBindingModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class UserBindingModel : IUserModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Login { get; set; } = string.Empty;
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
public int RoleId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IDisciplineLogic
|
||||||
|
{
|
||||||
|
bool Create(DisciplineBindingModel model);
|
||||||
|
bool Update(DisciplineBindingModel model);
|
||||||
|
bool Delete(DisciplineBindingModel model);
|
||||||
|
List<DisciplineViewModel>? ReadList(DisciplineSearchModel? model);
|
||||||
|
DisciplineViewModel? ReadElement(DisciplineSearchModel model);
|
||||||
|
}
|
||||||
|
}
|
20
UniversityContracts/BusinessLogicContracts/IDocumentLogic.cs
Normal file
20
UniversityContracts/BusinessLogicContracts/IDocumentLogic.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IDocumentLogic
|
||||||
|
{
|
||||||
|
bool Create(DocumentBindingModel model);
|
||||||
|
bool Update(DocumentBindingModel model);
|
||||||
|
bool Delete(DocumentBindingModel model);
|
||||||
|
List<DocumentViewModel>? ReadList(DocumentSearchModel? model);
|
||||||
|
DocumentViewModel? ReadElement(DocumentSearchModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IEducationGroupLogic
|
||||||
|
{
|
||||||
|
bool Create(EducationGroupBindingModel model);
|
||||||
|
bool Update(EducationGroupBindingModel model);
|
||||||
|
bool Delete(EducationGroupBindingModel model);
|
||||||
|
List<EducationGroupViewModel>? ReadList(EducationGroupSearchModel? model);
|
||||||
|
EducationGroupViewModel? ReadElement(EducationGroupSearchModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IEducationStatusLogic
|
||||||
|
{
|
||||||
|
bool Create(EducationStatusBindingModel model);
|
||||||
|
bool Update(EducationStatusBindingModel model);
|
||||||
|
bool Delete(EducationStatusBindingModel model);
|
||||||
|
List<EducationStatusViewModel>? ReadList(EducationStatusSearchModel? model);
|
||||||
|
EducationStatusViewModel? ReadElement(EducationStatusSearchModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IReportCustomerLogic
|
||||||
|
{
|
||||||
|
List<ReportDisciplineViewModel> GetDiscipline(ReportBindingModel model);
|
||||||
|
List<ReportStreamEducationStatusViewModel> StreamEducationStatus(List<StreamViewModel> streams);
|
||||||
|
|
||||||
|
void SaveBlanksToWordFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
void SaveDocumentBlankToExcelFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IReportProviderLogic
|
||||||
|
{
|
||||||
|
List<ReportStudentsDisciplineViewModel> GetStudentsDiscipline(List<StudentViewModel> students);
|
||||||
|
|
||||||
|
List<ReportStreamStudentEdStatPeriodViewModel> StreamStudentEdStatPeriod(ReportBindingModel model);
|
||||||
|
|
||||||
|
void SaveBlanksToWordFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
void SaveDocumentBlankToExcelFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
20
UniversityContracts/BusinessLogicContracts/IRoleLogic.cs
Normal file
20
UniversityContracts/BusinessLogicContracts/IRoleLogic.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IRoleLogic
|
||||||
|
{
|
||||||
|
List<RoleViewModel>? ReadList(RoleSearchModel? model);
|
||||||
|
RoleViewModel? ReadElement(RoleSearchModel model);
|
||||||
|
bool Create(RoleBindingModel model);
|
||||||
|
bool Update(RoleBindingModel model);
|
||||||
|
bool Delete(RoleBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
20
UniversityContracts/BusinessLogicContracts/IStreamLogic.cs
Normal file
20
UniversityContracts/BusinessLogicContracts/IStreamLogic.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IStreamLogic
|
||||||
|
{
|
||||||
|
bool Create(StreamBindingModel model);
|
||||||
|
bool Update(StreamBindingModel model);
|
||||||
|
bool Delete(StreamBindingModel model);
|
||||||
|
List<StreamViewModel>? ReadList(StreamSearchModel? model);
|
||||||
|
StreamViewModel? ReadElement(StreamSearchModel model);
|
||||||
|
}
|
||||||
|
}
|
20
UniversityContracts/BusinessLogicContracts/IStudentLogic.cs
Normal file
20
UniversityContracts/BusinessLogicContracts/IStudentLogic.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IStudentLogic
|
||||||
|
{
|
||||||
|
bool Create(StudentBindingModel model);
|
||||||
|
bool Update(StudentBindingModel model);
|
||||||
|
bool Delete(StudentBindingModel model);
|
||||||
|
List<StudentViewModel>? ReadList(StudentSearchModel? model);
|
||||||
|
StudentViewModel? ReadElement(StudentSearchModel model);
|
||||||
|
}
|
||||||
|
}
|
20
UniversityContracts/BusinessLogicContracts/IUserLogic.cs
Normal file
20
UniversityContracts/BusinessLogicContracts/IUserLogic.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IUserLogic
|
||||||
|
{
|
||||||
|
bool Create(UserBindingModel model);
|
||||||
|
bool Update(UserBindingModel model);
|
||||||
|
bool Delete(UserBindingModel model);
|
||||||
|
List<UserViewModel>? ReadList(UserSearchModel? model);
|
||||||
|
UserViewModel? ReadElement(UserSearchModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
namespace Contracts
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
16
UniversityContracts/SearchModels/DisciplineSearchModel.cs
Normal file
16
UniversityContracts/SearchModels/DisciplineSearchModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class DisciplineSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public int? StreamId { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
UniversityContracts/SearchModels/DocumentSearchModel.cs
Normal file
17
UniversityContracts/SearchModels/DocumentSearchModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class DocumentSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class EducationGroupSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
public int? NumberOfStudents { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class EducationStatusSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
UniversityContracts/SearchModels/RoleSearchModel.cs
Normal file
14
UniversityContracts/SearchModels/RoleSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class RoleSearchModel
|
||||||
|
{
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
UniversityContracts/SearchModels/StreamSearchModel.cs
Normal file
16
UniversityContracts/SearchModels/StreamSearchModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class StreamSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public int? Course { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
UniversityContracts/SearchModels/StudentSearchModel.cs
Normal file
18
UniversityContracts/SearchModels/StudentSearchModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class StudentSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public int? StudentCard { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
public bool? Disciplines { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
UniversityContracts/SearchModels/UserSearchModel.cs
Normal file
16
UniversityContracts/SearchModels/UserSearchModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class UserSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Login { get; set; }
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
21
UniversityContracts/StoragesContracts/IDisciplineStorage.cs
Normal file
21
UniversityContracts/StoragesContracts/IDisciplineStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IDisciplineStorage
|
||||||
|
{
|
||||||
|
List<DisciplineViewModel> GetFullList();
|
||||||
|
List<DisciplineViewModel> GetFilteredList(DisciplineSearchModel model);
|
||||||
|
DisciplineViewModel? GetElement(DisciplineSearchModel model);
|
||||||
|
DisciplineViewModel? Insert(DisciplineBindingModel model);
|
||||||
|
DisciplineViewModel? Update(DisciplineBindingModel model);
|
||||||
|
DisciplineViewModel? Delete(DisciplineBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
UniversityContracts/StoragesContracts/IDocumentStorage.cs
Normal file
21
UniversityContracts/StoragesContracts/IDocumentStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IDocumentStorage
|
||||||
|
{
|
||||||
|
List<DocumentViewModel> GetFullList();
|
||||||
|
List<DocumentViewModel> GetFilteredList(DocumentSearchModel model);
|
||||||
|
DocumentViewModel? GetElement(DocumentSearchModel model);
|
||||||
|
DocumentViewModel? Insert(DocumentBindingModel model);
|
||||||
|
DocumentViewModel? Update(DocumentBindingModel model);
|
||||||
|
DocumentViewModel? Delete(DocumentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IEducationGroupStorage
|
||||||
|
{
|
||||||
|
List<EducationGroupViewModel> GetFullList();
|
||||||
|
List<EducationGroupViewModel> GetFilteredList(EducationGroupSearchModel model);
|
||||||
|
EducationGroupViewModel? GetElement(EducationGroupSearchModel model);
|
||||||
|
EducationGroupViewModel? Insert(EducationGroupBindingModel model);
|
||||||
|
EducationGroupViewModel? Update(EducationGroupBindingModel model);
|
||||||
|
EducationGroupViewModel? Delete(EducationGroupBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IEducationStatusStorage
|
||||||
|
{
|
||||||
|
List<EducationStatusViewModel> GetFullList();
|
||||||
|
List<EducationStatusViewModel> GetFilteredList(EducationStatusSearchModel model);
|
||||||
|
EducationStatusViewModel? GetElement(EducationStatusSearchModel model);
|
||||||
|
EducationStatusViewModel? Insert(EducationStatusBindingModel model);
|
||||||
|
EducationStatusViewModel? Update(EducationStatusBindingModel model);
|
||||||
|
EducationStatusViewModel? Delete(EducationStatusBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
UniversityContracts/StoragesContracts/IRoleStorage.cs
Normal file
21
UniversityContracts/StoragesContracts/IRoleStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IRoleStorage
|
||||||
|
{
|
||||||
|
List<RoleViewModel> GetFullList();
|
||||||
|
List<RoleViewModel> GetFilteredList(RoleSearchModel model);
|
||||||
|
RoleViewModel? GetElement(RoleSearchModel model);
|
||||||
|
RoleViewModel? Insert(RoleBindingModel model);
|
||||||
|
RoleViewModel? Update(RoleBindingModel model);
|
||||||
|
RoleViewModel? Delete(RoleBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
UniversityContracts/StoragesContracts/IStreamStorage.cs
Normal file
21
UniversityContracts/StoragesContracts/IStreamStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IStreamStorage
|
||||||
|
{
|
||||||
|
List<StreamViewModel> GetFullList();
|
||||||
|
List<StreamViewModel> GetFilteredList(StreamSearchModel model);
|
||||||
|
StreamViewModel? GetElement(StreamSearchModel model);
|
||||||
|
StreamViewModel? Insert(StreamBindingModel model);
|
||||||
|
StreamViewModel? Update(StreamBindingModel model);
|
||||||
|
StreamViewModel? Delete(StreamBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
UniversityContracts/StoragesContracts/IStudentStorage.cs
Normal file
21
UniversityContracts/StoragesContracts/IStudentStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IStudentStorage
|
||||||
|
{
|
||||||
|
List<StudentViewModel> GetFullList();
|
||||||
|
List<StudentViewModel> GetFilteredList(StudentSearchModel model);
|
||||||
|
StudentViewModel? GetElement(StudentSearchModel model);
|
||||||
|
StudentViewModel? Insert(StudentBindingModel model);
|
||||||
|
StudentViewModel? Update(StudentBindingModel model);
|
||||||
|
StudentViewModel? Delete(StudentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
UniversityContracts/StoragesContracts/IUserStorage.cs
Normal file
21
UniversityContracts/StoragesContracts/IUserStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IUserStorage
|
||||||
|
{
|
||||||
|
List<UserViewModel> GetFullList();
|
||||||
|
List<UserViewModel> GetFilteredList(UserSearchModel model);
|
||||||
|
UserViewModel? GetElement(UserSearchModel model);
|
||||||
|
UserViewModel? Insert(UserBindingModel model);
|
||||||
|
UserViewModel? Update(UserBindingModel model);
|
||||||
|
UserViewModel? Delete(UserBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -6,4 +6,8 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UniversityModels\UniversityModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
23
UniversityContracts/ViewModels/DisciplineViewModel.cs
Normal file
23
UniversityContracts/ViewModels/DisciplineViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class DisciplineViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public int StreamId { get; set; }
|
||||||
|
[DisplayName("Название дисциплины")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Количество часов")]
|
||||||
|
public int Hours { get; set; } = 0;
|
||||||
|
[DisplayName("Тип оценки")]
|
||||||
|
public bool MarkType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
22
UniversityContracts/ViewModels/DocumentViewModel.cs
Normal file
22
UniversityContracts/ViewModels/DocumentViewModel.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class DocumentViewModel : IDocumentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[DisplayName("Название документа")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Дата создания документа")]
|
||||||
|
public DateTime Date { get; set; } = DateTime.Now;
|
||||||
|
public Dictionary<int, IStudentModel> StudentDocument { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
19
UniversityContracts/ViewModels/EducationGroupViewModel.cs
Normal file
19
UniversityContracts/ViewModels/EducationGroupViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class EducationGroupViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название группы")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Количество студентов в группе")]
|
||||||
|
public int NumberOfStudents { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
UniversityContracts/ViewModels/EducationStatusViewModel.cs
Normal file
18
UniversityContracts/ViewModels/EducationStatusViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class EducationStatusViewModel : IEducationStatusModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название документа")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
UniversityContracts/ViewModels/ReportDisciplineViewModel.cs
Normal file
15
UniversityContracts/ViewModels/ReportDisciplineViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportDisciplineViewModel
|
||||||
|
{
|
||||||
|
public string DisciplineName { get; set; } = string.Empty;
|
||||||
|
public List<(string StudentFIO, string DocumentDate, string EdStatus)> StudentEdStatus { get; set; } = new();
|
||||||
|
//выбираем дисциплину, выбираем период, отображаются студенты зачисленные через приказ в этот период со статусами обучения
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportStreamEducationStatusViewModel
|
||||||
|
{
|
||||||
|
public string StreamName { get; set; } = string.Empty;
|
||||||
|
public List<(string StudentFIO, string EdStatus)> StudentEdStatus { get; set; } = new();
|
||||||
|
// при выборе потока показывается список студентов на потоке и их статус обучения
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportStreamStudentEdStatPeriodViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string StreamName { get; set; } = string.Empty;
|
||||||
|
public List<(string StudentFIO, string EdStatus)> StudentEdStatus { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportStudentsDisciplineViewModel
|
||||||
|
{
|
||||||
|
public string StudentFIO { get; set; } = string.Empty;
|
||||||
|
public List<string> Disciplines { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
18
UniversityContracts/ViewModels/RoleViewModel.cs
Normal file
18
UniversityContracts/ViewModels/RoleViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class RoleViewModel : IRoleModel
|
||||||
|
{
|
||||||
|
[DisplayName("Название")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
21
UniversityContracts/ViewModels/StreamViewModel.cs
Normal file
21
UniversityContracts/ViewModels/StreamViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class StreamViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[DisplayName("Название потока")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Номер курса")]
|
||||||
|
public int Course { get; set; }
|
||||||
|
public Dictionary<int, IStudentModel> StudentStream { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
26
UniversityContracts/ViewModels/StudentViewModel.cs
Normal file
26
UniversityContracts/ViewModels/StudentViewModel.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class StudentViewModel : IStudentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[DisplayName("Имя студента")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Фамилия студента")]
|
||||||
|
public string Surname { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Дата рождения студента")]
|
||||||
|
public DateTime DateOfBirth { get; set; } = DateTime.Now;
|
||||||
|
[DisplayName("Статус обучения")]
|
||||||
|
public string EducationStatusName { get; set; } = string.Empty;
|
||||||
|
public int StudentCard { get; set; }
|
||||||
|
public int EducationStatusId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
19
UniversityContracts/ViewModels/UserViewModel.cs
Normal file
19
UniversityContracts/ViewModels/UserViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class UserViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int RoleId { get; set; }
|
||||||
|
[DisplayName("Логин")]
|
||||||
|
public string Login { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Пароль")]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
namespace UniversityDataBaseImplemet
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
30
UniversityDataBaseImplemet/Database.cs
Normal file
30
UniversityDataBaseImplemet/Database.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
using Stream = UniversityDataBaseImplemet.Models.Stream;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet
|
||||||
|
{
|
||||||
|
public class Database : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=University;Username=postgres;Password=postgres");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
public virtual DbSet<User> User { get; set; }
|
||||||
|
public virtual DbSet<Document> Documents { get; set; }
|
||||||
|
public virtual DbSet<Discipline> Discipline { get; set; }
|
||||||
|
public virtual DbSet<EducationStatus> EducationStatuses { get; set; }
|
||||||
|
public virtual DbSet<EducationGroup> EducationGroups { get; set; }
|
||||||
|
public virtual DbSet<EducationGroupDocument> EducationGroupsDocuments { get; set; }
|
||||||
|
public virtual DbSet<EducationGroupStream> EducationGroupsStreams { get; set; }
|
||||||
|
public virtual DbSet<Stream> Streams { get; set; }
|
||||||
|
public virtual DbSet<Student> Students { get; set; }
|
||||||
|
public virtual DbSet<StudentDocument> StudentDocuments { get; set; }
|
||||||
|
public virtual DbSet<StudentStream> StudentStreams { get; set; }
|
||||||
|
public virtual DbSet<Role> Roles { get; set; }
|
||||||
|
}
|
||||||
|
}
|
106
UniversityDataBaseImplemet/Implements/DisciplineStorage.cs
Normal file
106
UniversityDataBaseImplemet/Implements/DisciplineStorage.cs
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
|
{
|
||||||
|
public class DisciplineStorage:IDisciplineStorage
|
||||||
|
{
|
||||||
|
public DisciplineViewModel? GetElement(DisciplineSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Discipline
|
||||||
|
.FirstOrDefault(record => record.Id == model.Id
|
||||||
|
|| record.Name.Equals(model.Name))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public List<DisciplineViewModel> GetFilteredList(DisciplineSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.Discipline
|
||||||
|
.Where(record => record.Id.Equals(model.Id))
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Discipline
|
||||||
|
.Where(record => record.UserId == model.UserId)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<DisciplineViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Discipline
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public DisciplineViewModel? Insert(DisciplineBindingModel model)
|
||||||
|
{
|
||||||
|
var newDiscipline = Discipline.Create(model);
|
||||||
|
if (newDiscipline == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.Discipline.Add(newDiscipline);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newDiscipline.GetViewModel;
|
||||||
|
}
|
||||||
|
public DisciplineViewModel? Update(DisciplineBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var stream = context.Discipline
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (stream == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
stream.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
return stream.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public DisciplineViewModel? Delete(DisciplineBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var stream = context.Discipline
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (stream == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Discipline.Remove(stream);
|
||||||
|
context.SaveChanges();
|
||||||
|
return stream.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
139
UniversityDataBaseImplemet/Implements/DocumentStorage.cs
Normal file
139
UniversityDataBaseImplemet/Implements/DocumentStorage.cs
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
|
{
|
||||||
|
public class DocumentStorage : IDocumentStorage
|
||||||
|
{
|
||||||
|
public DocumentViewModel? GetElement(DocumentSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Documents
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.Students)
|
||||||
|
.ThenInclude(record => record.Student)
|
||||||
|
.FirstOrDefault(record => record.Id == model.Id
|
||||||
|
|| record.Name.Equals(model.Name))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public List<DocumentViewModel> GetFilteredList(DocumentSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.Documents
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.Students)
|
||||||
|
.ThenInclude(record => record.Student)
|
||||||
|
.Where(record => record.Id.Equals(model.Id))
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.DateFrom != null && model.DateTo != null && model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Documents
|
||||||
|
.Where(d => d.Date >= model.DateFrom && d.Date <= model.DateTo && d.UserId == model.UserId)
|
||||||
|
.Include(d => d.Students)
|
||||||
|
.ThenInclude(sd => sd.Student)
|
||||||
|
.ThenInclude(s => s.StudentStream)
|
||||||
|
.ThenInclude(ss => ss.Stream)
|
||||||
|
.Include(d => d.Students)
|
||||||
|
.ThenInclude(sd => sd.Student)
|
||||||
|
.ThenInclude(s => s.EducationStatus)
|
||||||
|
.Select(result => result.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Documents
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.Students)
|
||||||
|
.ThenInclude(record => record.Student)
|
||||||
|
.Where(record => record.UserId == model.UserId)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<DocumentViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Documents
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.Students)
|
||||||
|
.ThenInclude(record => record.Student)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public DocumentViewModel? Insert(DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
var newDocument = Document.Create(model);
|
||||||
|
if(newDocument == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.Documents.Add(newDocument);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newDocument.GetViewModel;
|
||||||
|
}
|
||||||
|
public DocumentViewModel? Update(DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var document = context.Documents
|
||||||
|
.Include(record => record.User)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (document == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
document.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
document.UpdateStudents(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
return document.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public DocumentViewModel? Delete(DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var document = context.Documents
|
||||||
|
.Include(record => record.User)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (document == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Documents.Remove(document);
|
||||||
|
context.SaveChanges();
|
||||||
|
return document.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
105
UniversityDataBaseImplemet/Implements/EducationGroupStorage.cs
Normal file
105
UniversityDataBaseImplemet/Implements/EducationGroupStorage.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
|
{
|
||||||
|
public class EducationGroupStorage
|
||||||
|
{
|
||||||
|
public EducationGroupViewModel? GetElement(EducationGroupSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.EducationGroups
|
||||||
|
.FirstOrDefault(record => record.Id == model.Id
|
||||||
|
|| record.Name.Equals(model.Name))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public List<EducationGroupViewModel> GetFilteredList(EducationGroupSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.EducationGroups
|
||||||
|
.Where(record => record.Id.Equals(model.Id))
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return context.EducationGroups
|
||||||
|
.Where(record => record.UserId == model.UserId)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<EducationGroupViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.EducationGroups
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public EducationGroupViewModel? Insert(EducationGroupBindingModel model)
|
||||||
|
{
|
||||||
|
var newEducationGroup = EducationGroup.Create(model);
|
||||||
|
if (newEducationGroup == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.EducationGroups.Add(newEducationGroup);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newEducationGroup.GetViewModel;
|
||||||
|
}
|
||||||
|
public EducationGroupViewModel? Update(EducationGroupBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var educationgroup = context.EducationGroups
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (educationgroup == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
educationgroup.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
return educationgroup.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public EducationGroupViewModel? Delete(EducationGroupBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var educationgroup = context.EducationGroups
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (educationgroup == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.EducationGroups.Remove(educationgroup);
|
||||||
|
context.SaveChanges();
|
||||||
|
return educationgroup.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
116
UniversityDataBaseImplemet/Implements/EducationStatusStorage.cs
Normal file
116
UniversityDataBaseImplemet/Implements/EducationStatusStorage.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
|
{
|
||||||
|
public class EducationStatusStorage : IEducationStatusStorage
|
||||||
|
{
|
||||||
|
public EducationStatusViewModel? GetElement(EducationStatusSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.EducationStatuses
|
||||||
|
.Include(record => record.User)
|
||||||
|
.FirstOrDefault(record => record.Id == model.Id
|
||||||
|
|| record.Name.Equals(model.Name))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public List<EducationStatusViewModel> GetFilteredList(EducationStatusSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.EducationStatuses
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Where(record => record.Id.Equals(model.Id))
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return context.EducationStatuses
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Where(record => record.UserId == model.UserId)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<EducationStatusViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.EducationStatuses
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public EducationStatusViewModel? Insert(EducationStatusBindingModel model)
|
||||||
|
{
|
||||||
|
var newEducationStatus = EducationStatus.Create(model);
|
||||||
|
if (newEducationStatus == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.EducationStatuses.Add(newEducationStatus);
|
||||||
|
context.SaveChanges();
|
||||||
|
return context.EducationStatuses
|
||||||
|
.Include(record => record.User)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(newEducationStatus.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public EducationStatusViewModel? Update(EducationStatusBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var educationStatus = context.EducationStatuses
|
||||||
|
.Include(record => record.User)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (educationStatus == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
educationStatus.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
return educationStatus.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public EducationStatusViewModel? Delete(EducationStatusBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var educationStatus = context.EducationStatuses
|
||||||
|
.Include(record => record.User)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (educationStatus == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.EducationStatuses.Remove(educationStatus);
|
||||||
|
context.SaveChanges();
|
||||||
|
return educationStatus.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
89
UniversityDataBaseImplemet/Implements/RoleStorage.cs
Normal file
89
UniversityDataBaseImplemet/Implements/RoleStorage.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
|
{
|
||||||
|
public class RoleStorage : IRoleStorage
|
||||||
|
{
|
||||||
|
public RoleViewModel? Delete(RoleBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var element = context.Roles
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Roles.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleViewModel? GetElement(RoleSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
return context.Roles
|
||||||
|
.FirstOrDefault(record => record.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
if (!string.IsNullOrEmpty(model.Name))
|
||||||
|
return context.Roles
|
||||||
|
.FirstOrDefault(record => record.Name.Equals(model.Name))
|
||||||
|
?.GetViewModel;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RoleViewModel> GetFilteredList(RoleSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Roles
|
||||||
|
.Where(record => record.Name.Contains(model.Name))
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RoleViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Roles.Select(record => record.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleViewModel? Insert(RoleBindingModel model)
|
||||||
|
{
|
||||||
|
var newRole = Role.Create(model);
|
||||||
|
if (newRole == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.Roles.Add(newRole);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newRole.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleViewModel? Update(RoleBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var client = context.Roles.FirstOrDefault(record => record.Id == model.Id);
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
client.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
116
UniversityDataBaseImplemet/Implements/StreamStorage.cs
Normal file
116
UniversityDataBaseImplemet/Implements/StreamStorage.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using Stream = UniversityDataBaseImplemet.Models.Stream;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
|
{
|
||||||
|
public class StreamStorage:IStreamStorage
|
||||||
|
{
|
||||||
|
public StreamViewModel? GetElement(StreamSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Streams
|
||||||
|
.Include(record => record.StreamStudents)
|
||||||
|
.ThenInclude(record => record.Student)
|
||||||
|
.FirstOrDefault(record => record.Id == model.Id
|
||||||
|
|| record.Name.Equals(model.Name))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public List<StreamViewModel> GetFilteredList(StreamSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.Streams
|
||||||
|
.Include(record => record.StreamStudents)
|
||||||
|
.ThenInclude(record => record.Student)
|
||||||
|
.Where(record => record.Id.Equals(model.Id))
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Streams
|
||||||
|
.Include(record => record.StreamStudents)
|
||||||
|
.ThenInclude(record => record.Student)
|
||||||
|
.Where(record => record.UserId == model.UserId)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<StreamViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Streams
|
||||||
|
.Include(record => record.StreamStudents)
|
||||||
|
.ThenInclude(record => record.Student)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public StreamViewModel? Insert(StreamBindingModel model)
|
||||||
|
{
|
||||||
|
var newStream = Stream.Create(model);
|
||||||
|
if (newStream == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.Streams.Add(newStream);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newStream.GetViewModel;
|
||||||
|
}
|
||||||
|
public StreamViewModel? Update(StreamBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var stream = context.Streams
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (stream == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
stream.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
stream.UpdateStreamStudents(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
return stream.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public StreamViewModel? Delete(StreamBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var stream = context.Streams
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (stream == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Streams.Remove(stream);
|
||||||
|
context.SaveChanges();
|
||||||
|
return stream.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
121
UniversityDataBaseImplemet/Implements/StudentStorage.cs
Normal file
121
UniversityDataBaseImplemet/Implements/StudentStorage.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
|
{
|
||||||
|
public class StudentStorage : IStudentStorage
|
||||||
|
{
|
||||||
|
public StudentViewModel? GetElement(StudentSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue && model.StudentCard <= 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Students
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.EducationStatus)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id)
|
||||||
|
|| record.StudentCard.Equals(model.StudentCard))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public List<StudentViewModel> GetFilteredList(StudentSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.Students
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.EducationStatus)
|
||||||
|
.Where(record => record.Id.Equals(model.Id))
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Students
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.EducationStatus)
|
||||||
|
.Where(record => record.UserId == model.UserId)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<StudentViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Students
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.EducationStatus)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public StudentViewModel? Insert(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
var newStudent = Student.Create(model);
|
||||||
|
if (newStudent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.Students.Add(newStudent);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newStudent.GetViewModel;
|
||||||
|
}
|
||||||
|
public StudentViewModel? Update(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var student = context.Students
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.EducationStatus)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
student.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
return student.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public StudentViewModel? Delete(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var student = context.Students
|
||||||
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.EducationStatus)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Students.Remove(student);
|
||||||
|
context.SaveChanges();
|
||||||
|
return student.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
101
UniversityDataBaseImplemet/Implements/UserStorage.cs
Normal file
101
UniversityDataBaseImplemet/Implements/UserStorage.cs
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
|
{
|
||||||
|
public class UserStorage : IUserStorage
|
||||||
|
{
|
||||||
|
public UserViewModel? Delete(UserBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var user = context.User
|
||||||
|
.Include(record => record.Role)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.User.Remove(user);
|
||||||
|
context.SaveChanges();
|
||||||
|
return user.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserViewModel? GetElement(UserSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.User
|
||||||
|
.Include(record => record.Role)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserViewModel> GetFilteredList(UserSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.User
|
||||||
|
.Include(record => record.Role)
|
||||||
|
.Where(record => record.Id.Equals(model.Id))
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.User
|
||||||
|
.Include(record => record.Role)
|
||||||
|
.Select(record => record.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserViewModel? Insert(UserBindingModel model)
|
||||||
|
{
|
||||||
|
var newUser = User.Create(model);
|
||||||
|
if (newUser == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.User.Add(newUser);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newUser.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserViewModel? Update(UserBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var user = context.User
|
||||||
|
.Include(record => record.Role)
|
||||||
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
user.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
return user.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
UniversityDataBaseImplemet/Models/Discipline.cs
Normal file
66
UniversityDataBaseImplemet/Models/Discipline.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class Discipline : IDisciplineModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int StreamId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int Hours { get; set; }
|
||||||
|
[Required]
|
||||||
|
public bool MarkType { get; set; }
|
||||||
|
|
||||||
|
public virtual Stream Stream { get; set; }
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public static Discipline? Create(DisciplineBindingModel model)
|
||||||
|
{
|
||||||
|
return new Discipline()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
UserId = model.UserId,
|
||||||
|
StreamId = model.StreamId,
|
||||||
|
Hours= model.Hours,
|
||||||
|
MarkType = model.MarkType
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(DisciplineBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
UserId = model.UserId;
|
||||||
|
StreamId = model.StreamId;
|
||||||
|
Hours = model.Hours;
|
||||||
|
MarkType = model.MarkType;
|
||||||
|
}
|
||||||
|
public DisciplineViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
UserId = UserId,
|
||||||
|
StreamId = StreamId,
|
||||||
|
Hours = Hours,
|
||||||
|
MarkType = MarkType
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
101
UniversityDataBaseImplemet/Models/Document.cs
Normal file
101
UniversityDataBaseImplemet/Models/Document.cs
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class Document : IDocumentModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[ForeignKey("DocumentId")]
|
||||||
|
public virtual List<StudentDocument> Students { get; set; } = new();
|
||||||
|
[ForeignKey("DocumentId")]
|
||||||
|
public virtual List<EducationGroupDocument> EducationGroupDocument { get; set; } = new();
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
private Dictionary<int, IStudentModel>? _studentDocument = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, IStudentModel> StudentDocument
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_studentDocument == null)
|
||||||
|
{
|
||||||
|
_studentDocument = Students.ToDictionary(rec => rec.StudentId, rec => rec.Student as IStudentModel);
|
||||||
|
}
|
||||||
|
return _studentDocument;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Document? Create(DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
return new Document()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Date = model.Date,
|
||||||
|
UserId = model.UserId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
if(model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
Date = model.Date;
|
||||||
|
UserId = model.UserId;
|
||||||
|
}
|
||||||
|
public void UpdateStudents(Database context, DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
var studentDocument = context.StudentDocuments
|
||||||
|
.Where(rec => rec.DocumentId == model.Id)
|
||||||
|
.ToList();
|
||||||
|
if (studentDocument != null)
|
||||||
|
{
|
||||||
|
context.StudentDocuments
|
||||||
|
.RemoveRange(studentDocument
|
||||||
|
.Where(rec => !model.StudentDocument
|
||||||
|
.ContainsKey(rec.StudentId))
|
||||||
|
);
|
||||||
|
context.SaveChanges();
|
||||||
|
var document = context.Documents
|
||||||
|
.First(x => x.Id == Id);
|
||||||
|
foreach (var sd in studentDocument)
|
||||||
|
{
|
||||||
|
model.StudentDocument.Remove(sd.StudentId);
|
||||||
|
}
|
||||||
|
foreach (var sd in model.StudentDocument)
|
||||||
|
{
|
||||||
|
context.StudentDocuments.Add(new StudentDocument
|
||||||
|
{
|
||||||
|
Document = document,
|
||||||
|
Student = context.Students.First(x => x.Id == sd.Key),
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_studentDocument = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public DocumentViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Date = Date,
|
||||||
|
UserId = UserId,
|
||||||
|
StudentDocument = StudentDocument
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
57
UniversityDataBaseImplemet/Models/EducationGroup.cs
Normal file
57
UniversityDataBaseImplemet/Models/EducationGroup.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class EducationGroup : IEducationGroupModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public int NumberOfStudent { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[ForeignKey("EducationGroupId")]
|
||||||
|
public virtual List<EducationGroupDocument> EducationGroupDocument { get; set; } = new();
|
||||||
|
[ForeignKey("EducationGroupId")]
|
||||||
|
public virtual List<EducationGroupStream> EducationGroupStream { get; set; } = new();
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
|
public static EducationGroup? Create(EducationGroupBindingModel model)
|
||||||
|
{
|
||||||
|
return new EducationGroup()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
UserId = model.UserId,
|
||||||
|
NumberOfStudent= model.NumberOfStudent
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(EducationGroupBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
UserId = model.UserId;
|
||||||
|
}
|
||||||
|
public EducationGroupViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
UserId = UserId,
|
||||||
|
NumberOfStudents= NumberOfStudent
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
20
UniversityDataBaseImplemet/Models/EducationGroupDocument.cs
Normal file
20
UniversityDataBaseImplemet/Models/EducationGroupDocument.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class EducationGroupDocument
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int EducationGroupId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int DocumentId { get; set; }
|
||||||
|
public virtual Document Document { get; set; } = new();
|
||||||
|
public virtual EducationGroup EducationGroup { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
20
UniversityDataBaseImplemet/Models/EducationGroupStream.cs
Normal file
20
UniversityDataBaseImplemet/Models/EducationGroupStream.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class EducationGroupStream
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int EducationGroupId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int StreamId { get; set; }
|
||||||
|
public virtual Stream Stream { get; set; } = new();
|
||||||
|
public virtual EducationGroup EducationGroup { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
50
UniversityDataBaseImplemet/Models/EducationStatus.cs
Normal file
50
UniversityDataBaseImplemet/Models/EducationStatus.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class EducationStatus : IEducationStatusModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[ForeignKey("EducationStatusId")]
|
||||||
|
public virtual List<Student> Students { get; set; } = new();
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
|
public static EducationStatus? Create(EducationStatusBindingModel model)
|
||||||
|
{
|
||||||
|
return new EducationStatus()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
UserId = model.UserId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(EducationStatusBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
UserId = model.UserId;
|
||||||
|
}
|
||||||
|
public EducationStatusViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
UserId = UserId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
58
UniversityDataBaseImplemet/Models/Role.cs
Normal file
58
UniversityDataBaseImplemet/Models/Role.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class Role : IRoleModel
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("RoleId")]
|
||||||
|
public virtual List<User> Users { get; set; } = new();
|
||||||
|
|
||||||
|
public static Role? Create(RoleBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Role()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Role Create(RoleViewModel model)
|
||||||
|
{
|
||||||
|
return new Role
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(RoleBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
|
||||||
|
}
|
||||||
|
public RoleViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
94
UniversityDataBaseImplemet/Models/Stream.cs
Normal file
94
UniversityDataBaseImplemet/Models/Stream.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class Stream : IStreamModel
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int Course { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[ForeignKey("StreamId")]
|
||||||
|
public virtual List<EducationGroupStream> EducationGroupStream { get; set; } = new();
|
||||||
|
[ForeignKey("StreamId")]
|
||||||
|
public virtual List<StudentStream> StreamStudents { get; set; } = new();
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
private Dictionary<int, IStudentModel>? _studentStream = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, IStudentModel> StudentStream
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_studentStream == null)
|
||||||
|
{
|
||||||
|
_studentStream = StreamStudents.ToDictionary(rec => rec.StudentId, rec => rec.Student as IStudentModel);
|
||||||
|
}
|
||||||
|
return _studentStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Stream Create(StreamBindingModel model)
|
||||||
|
{
|
||||||
|
return new Stream()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Course = model.Course,
|
||||||
|
UserId = model.UserId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(StreamBindingModel model)
|
||||||
|
{
|
||||||
|
Name = model.Name;
|
||||||
|
Course = model.Course;
|
||||||
|
UserId = model.UserId;
|
||||||
|
}
|
||||||
|
public void UpdateStreamStudents(Database context, StreamBindingModel model)
|
||||||
|
{
|
||||||
|
var studentStream = context.StudentStreams
|
||||||
|
.Where(rec => rec.StreamId == model.Id)
|
||||||
|
.ToList();
|
||||||
|
if (studentStream != null)
|
||||||
|
{
|
||||||
|
context.StudentStreams
|
||||||
|
.RemoveRange(studentStream
|
||||||
|
.Where(rec => !model.StudentStream
|
||||||
|
.ContainsKey(rec.StudentId))
|
||||||
|
);
|
||||||
|
context.SaveChanges();
|
||||||
|
var stream = context.Streams
|
||||||
|
.First(x => x.Id == Id);
|
||||||
|
foreach (var sd in studentStream)
|
||||||
|
{
|
||||||
|
model.StudentStream.Remove(sd.StudentId);
|
||||||
|
}
|
||||||
|
foreach (var sd in model.StudentStream)
|
||||||
|
{
|
||||||
|
context.StudentStreams.Add(new StudentStream
|
||||||
|
{
|
||||||
|
Stream = stream,
|
||||||
|
Student = context.Students.First(x => x.Id == sd.Key),
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_studentStream = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public StreamViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
UserId = UserId,
|
||||||
|
Course= Course
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
66
UniversityDataBaseImplemet/Models/Student.cs
Normal file
66
UniversityDataBaseImplemet/Models/Student.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class Student : IStudentModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Surname { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int StudentCard { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int EducationStatusId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[ForeignKey("StudentId")]
|
||||||
|
public virtual List<StudentDocument> DocumentStudents { get; set; } = new();
|
||||||
|
[ForeignKey("StudentId")]
|
||||||
|
public virtual List<StudentStream> StudentStream { get; set; } = new();
|
||||||
|
public virtual EducationStatus EducationStatus { get; set; }
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
|
public static Student Create(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
return new Student()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Surname = model.Surname,
|
||||||
|
DateOfBirth = model.DateOfBirth,
|
||||||
|
StudentCard = model.StudentCard,
|
||||||
|
EducationStatusId = model.EducationStatusId,
|
||||||
|
UserId = model.UserId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
StudentCard = model.StudentCard;
|
||||||
|
EducationStatusId = model.EducationStatusId;
|
||||||
|
}
|
||||||
|
public StudentViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Surname = Surname,
|
||||||
|
DateOfBirth = DateOfBirth,
|
||||||
|
StudentCard = StudentCard,
|
||||||
|
EducationStatusId = EducationStatusId,
|
||||||
|
UserId = UserId,
|
||||||
|
EducationStatusName = EducationStatus.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
20
UniversityDataBaseImplemet/Models/StudentDocument.cs
Normal file
20
UniversityDataBaseImplemet/Models/StudentDocument.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class StudentDocument
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int StudentId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int DocumentId { get; set; }
|
||||||
|
public virtual Student Student { get; set; } = new();
|
||||||
|
public virtual Document Document { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
20
UniversityDataBaseImplemet/Models/StudentStream.cs
Normal file
20
UniversityDataBaseImplemet/Models/StudentStream.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class StudentStream
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int StudentId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int StreamId { get; set; }
|
||||||
|
public virtual Student Student { get; set; } = new();
|
||||||
|
public virtual Stream Stream { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
47
UniversityDataBaseImplemet/Models/User.cs
Normal file
47
UniversityDataBaseImplemet/Models/User.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Models
|
||||||
|
{
|
||||||
|
public class User : IUserModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string Login { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int RoleId { get; set; }
|
||||||
|
public virtual Role Role { get; set; } = new();
|
||||||
|
public static User Create(UserBindingModel model)
|
||||||
|
{
|
||||||
|
return new User()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Login = model.Login,
|
||||||
|
Password = model.Password,
|
||||||
|
RoleId = model.RoleId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(UserBindingModel model)
|
||||||
|
{
|
||||||
|
Password = model.Password;
|
||||||
|
RoleId = model.RoleId;
|
||||||
|
}
|
||||||
|
public UserViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Login = Login,
|
||||||
|
Password = Password,
|
||||||
|
RoleId = RoleId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -6,4 +6,18 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Migrations\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\UniversityModels\UniversityModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
namespace UniversityModels
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
13
UniversityModels/IId.cs
Normal file
13
UniversityModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels
|
||||||
|
{
|
||||||
|
public interface IId
|
||||||
|
{
|
||||||
|
int Id { get; }
|
||||||
|
}
|
||||||
|
}
|
17
UniversityModels/Models/IDisciplineModel.cs
Normal file
17
UniversityModels/Models/IDisciplineModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels.Models
|
||||||
|
{
|
||||||
|
public interface IDisciplineModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
int Hours { get; }
|
||||||
|
bool MarkType { get; }
|
||||||
|
int StreamId { get; }
|
||||||
|
int UserId { get; }
|
||||||
|
}
|
||||||
|
}
|
16
UniversityModels/Models/IDocumentModel.cs
Normal file
16
UniversityModels/Models/IDocumentModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels.Models
|
||||||
|
{
|
||||||
|
public interface IDocumentModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
DateTime Date { get; }
|
||||||
|
int UserId { get; }
|
||||||
|
Dictionary <int, IStudentModel> StudentDocument { get; }
|
||||||
|
}
|
||||||
|
}
|
15
UniversityModels/Models/IEducationGroupModel.cs
Normal file
15
UniversityModels/Models/IEducationGroupModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels.Models
|
||||||
|
{
|
||||||
|
public interface IEducationGroupModel:IId
|
||||||
|
{
|
||||||
|
string Name { get;}
|
||||||
|
int NumberOfStudent { get;}
|
||||||
|
int UserId { get;}
|
||||||
|
}
|
||||||
|
}
|
14
UniversityModels/Models/IEducationStatusModel.cs
Normal file
14
UniversityModels/Models/IEducationStatusModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels.Models
|
||||||
|
{
|
||||||
|
public interface IEducationStatusModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
int UserId { get; }
|
||||||
|
}
|
||||||
|
}
|
13
UniversityModels/Models/IRoleModel.cs
Normal file
13
UniversityModels/Models/IRoleModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels.Models
|
||||||
|
{
|
||||||
|
public interface IRoleModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
}
|
||||||
|
}
|
17
UniversityModels/Models/IStreamModel.cs
Normal file
17
UniversityModels/Models/IStreamModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels.Models
|
||||||
|
{
|
||||||
|
public interface IStreamModel:IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
int Course { get; }
|
||||||
|
int UserId { get; }
|
||||||
|
|
||||||
|
Dictionary<int, IStudentModel> StudentStream { get; }
|
||||||
|
}
|
||||||
|
}
|
18
UniversityModels/Models/IStudentModel.cs
Normal file
18
UniversityModels/Models/IStudentModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels.Models
|
||||||
|
{
|
||||||
|
public interface IStudentModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
string Surname { get; }
|
||||||
|
DateTime DateOfBirth { get; }
|
||||||
|
int StudentCard { get; }
|
||||||
|
int EducationStatusId { get; }
|
||||||
|
int UserId { get; }
|
||||||
|
}
|
||||||
|
}
|
16
UniversityModels/Models/IUserModel.cs
Normal file
16
UniversityModels/Models/IUserModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UniversityModels.Models
|
||||||
|
{
|
||||||
|
public interface IUserModel
|
||||||
|
{
|
||||||
|
string Login { get; }
|
||||||
|
string Password { get; }
|
||||||
|
int RoleId { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
UniversityProvider/Controllers/HomeController.cs
Normal file
32
UniversityProvider/Controllers/HomeController.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using UniversityProvider.Models;
|
||||||
|
|
||||||
|
namespace UniversityProvider.Controllers
|
||||||
|
{
|
||||||
|
public class HomeController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
|
public HomeController(ILogger<HomeController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Privacy()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
UniversityProvider/Models/ErrorViewModel.cs
Normal file
9
UniversityProvider/Models/ErrorViewModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace UniversityProvider.Models
|
||||||
|
{
|
||||||
|
public class ErrorViewModel
|
||||||
|
{
|
||||||
|
public string? RequestId { get; set; }
|
||||||
|
|
||||||
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user