diff --git a/UniversityBusinessLogic/BusinessLogics/DisciplineLogic.cs b/UniversityBusinessLogic/BusinessLogics/DisciplineLogic.cs new file mode 100644 index 0000000..98a1693 --- /dev/null +++ b/UniversityBusinessLogic/BusinessLogics/DisciplineLogic.cs @@ -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? 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("Дисциплина с таким названием уже есть"); + } + } + } +} diff --git a/UniversityBusinessLogic/BusinessLogics/EducationGroupLogic.cs b/UniversityBusinessLogic/BusinessLogics/EducationGroupLogic.cs new file mode 100644 index 0000000..ad3c95f --- /dev/null +++ b/UniversityBusinessLogic/BusinessLogics/EducationGroupLogic.cs @@ -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? 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("Статус с таким названием уже есть"); + } + } + } +} diff --git a/UniversityBusinessLogic/BusinessLogics/StreamLogic.cs b/UniversityBusinessLogic/BusinessLogics/StreamLogic.cs new file mode 100644 index 0000000..e1f246f --- /dev/null +++ b/UniversityBusinessLogic/BusinessLogics/StreamLogic.cs @@ -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? 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)); + } + } + } +} diff --git a/UniversityContracts/BindingModels/DisciplineBindingModel.cs b/UniversityContracts/BindingModels/DisciplineBindingModel.cs new file mode 100644 index 0000000..75cd0ef --- /dev/null +++ b/UniversityContracts/BindingModels/DisciplineBindingModel.cs @@ -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; } + } +} diff --git a/UniversityContracts/BindingModels/EducationGroupBindingModel.cs b/UniversityContracts/BindingModels/EducationGroupBindingModel.cs new file mode 100644 index 0000000..084436e --- /dev/null +++ b/UniversityContracts/BindingModels/EducationGroupBindingModel.cs @@ -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; } + } +} diff --git a/UniversityContracts/BindingModels/StreamBindingModel.cs b/UniversityContracts/BindingModels/StreamBindingModel.cs new file mode 100644 index 0000000..5bb6aff --- /dev/null +++ b/UniversityContracts/BindingModels/StreamBindingModel.cs @@ -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 StreamBindingModel : IStreamModel + { + public string Name { get; set; } = string.Empty; + + public int Course { get; set; } + + public int UserId { get; set; } + + public int Id { get; set; } + } +} diff --git a/UniversityContracts/BusinessLogicContracts/IDisciplineLogic.cs b/UniversityContracts/BusinessLogicContracts/IDisciplineLogic.cs new file mode 100644 index 0000000..ca0f352 --- /dev/null +++ b/UniversityContracts/BusinessLogicContracts/IDisciplineLogic.cs @@ -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? ReadList(DisciplineSearchModel? model); + DisciplineViewModel? ReadElement(DisciplineSearchModel model); + } +} diff --git a/UniversityContracts/BusinessLogicContracts/IEducationGroupLogic.cs b/UniversityContracts/BusinessLogicContracts/IEducationGroupLogic.cs new file mode 100644 index 0000000..9277ff8 --- /dev/null +++ b/UniversityContracts/BusinessLogicContracts/IEducationGroupLogic.cs @@ -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? ReadList(EducationGroupSearchModel? model); + EducationGroupViewModel? ReadElement(EducationGroupSearchModel model); + } +} diff --git a/UniversityContracts/BusinessLogicContracts/IStreamLogic.cs b/UniversityContracts/BusinessLogicContracts/IStreamLogic.cs new file mode 100644 index 0000000..d93de12 --- /dev/null +++ b/UniversityContracts/BusinessLogicContracts/IStreamLogic.cs @@ -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? ReadList(StreamSearchModel? model); + StreamViewModel? ReadElement(StreamSearchModel model); + } +} diff --git a/UniversityContracts/SearchModels/DisciplineSearchModel.cs b/UniversityContracts/SearchModels/DisciplineSearchModel.cs new file mode 100644 index 0000000..267276e --- /dev/null +++ b/UniversityContracts/SearchModels/DisciplineSearchModel.cs @@ -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; } + } +} diff --git a/UniversityContracts/SearchModels/EducationGroupSearchModel.cs b/UniversityContracts/SearchModels/EducationGroupSearchModel.cs new file mode 100644 index 0000000..2925330 --- /dev/null +++ b/UniversityContracts/SearchModels/EducationGroupSearchModel.cs @@ -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; } + } +} diff --git a/UniversityContracts/SearchModels/StreamSearchModel.cs b/UniversityContracts/SearchModels/StreamSearchModel.cs new file mode 100644 index 0000000..08999eb --- /dev/null +++ b/UniversityContracts/SearchModels/StreamSearchModel.cs @@ -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; } + } +} diff --git a/UniversityContracts/StoragesContracts/IDisciplineStorage.cs b/UniversityContracts/StoragesContracts/IDisciplineStorage.cs new file mode 100644 index 0000000..60fcd26 --- /dev/null +++ b/UniversityContracts/StoragesContracts/IDisciplineStorage.cs @@ -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 GetFullList(); + List GetFilteredList(DisciplineSearchModel model); + DisciplineViewModel? GetElement(DisciplineSearchModel model); + DisciplineViewModel? Insert(DisciplineBindingModel model); + DisciplineViewModel? Update(DisciplineBindingModel model); + DisciplineViewModel? Delete(DisciplineBindingModel model); + } +} diff --git a/UniversityContracts/StoragesContracts/IEducationGroupStorage.cs b/UniversityContracts/StoragesContracts/IEducationGroupStorage.cs new file mode 100644 index 0000000..4f55591 --- /dev/null +++ b/UniversityContracts/StoragesContracts/IEducationGroupStorage.cs @@ -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 GetFullList(); + List GetFilteredList(EducationGroupSearchModel model); + EducationGroupViewModel? GetElement(EducationGroupSearchModel model); + EducationGroupViewModel? Insert(EducationGroupBindingModel model); + EducationGroupViewModel? Update(EducationGroupBindingModel model); + EducationGroupViewModel? Delete(EducationGroupBindingModel model); + } +} diff --git a/UniversityContracts/StoragesContracts/IStreamStorage.cs b/UniversityContracts/StoragesContracts/IStreamStorage.cs new file mode 100644 index 0000000..e9cc104 --- /dev/null +++ b/UniversityContracts/StoragesContracts/IStreamStorage.cs @@ -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 GetFullList(); + List GetFilteredList(StreamSearchModel model); + StreamViewModel? GetElement(StreamSearchModel model); + StreamViewModel? Insert(StreamBindingModel model); + StreamViewModel? Update(StreamBindingModel model); + StreamViewModel? Delete(StreamBindingModel model); + } +} diff --git a/UniversityContracts/ViewModels/DisciplineViewModel.cs b/UniversityContracts/ViewModels/DisciplineViewModel.cs new file mode 100644 index 0000000..75a67f1 --- /dev/null +++ b/UniversityContracts/ViewModels/DisciplineViewModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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; } //TODO уточнить + } +} diff --git a/UniversityContracts/ViewModels/EducationGroupViewModel.cs b/UniversityContracts/ViewModels/EducationGroupViewModel.cs new file mode 100644 index 0000000..97dfd3a --- /dev/null +++ b/UniversityContracts/ViewModels/EducationGroupViewModel.cs @@ -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; } + } +} diff --git a/UniversityContracts/ViewModels/StreamViewModel.cs b/UniversityContracts/ViewModels/StreamViewModel.cs new file mode 100644 index 0000000..412e6e5 --- /dev/null +++ b/UniversityContracts/ViewModels/StreamViewModel.cs @@ -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 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; } + } +} diff --git a/UniversityDataBaseImplemet/Models/Discipline.cs b/UniversityDataBaseImplemet/Models/Discipline.cs new file mode 100644 index 0000000..3d9359e --- /dev/null +++ b/UniversityDataBaseImplemet/Models/Discipline.cs @@ -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 + }; + } +} diff --git a/UniversityDataBaseImplemet/Models/Document.cs b/UniversityDataBaseImplemet/Models/Document.cs index f4f24b0..700e956 100644 --- a/UniversityDataBaseImplemet/Models/Document.cs +++ b/UniversityDataBaseImplemet/Models/Document.cs @@ -22,7 +22,9 @@ namespace UniversityDataBaseImplemet.Models public int UserId { get; set; } [ForeignKey("DocumentId")] public virtual List Students { get; set; } = new(); - public virtual EducationStatus User { get; set; } + [ForeignKey("DocumentId")] + public virtual List EducationGroupDocument { get; set; } = new(); + public virtual User User { get; set; } public static Document? Create(DocumentBindingModel model) { diff --git a/UniversityDataBaseImplemet/Models/EducationGroup.cs b/UniversityDataBaseImplemet/Models/EducationGroup.cs new file mode 100644 index 0000000..2bc7079 --- /dev/null +++ b/UniversityDataBaseImplemet/Models/EducationGroup.cs @@ -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 { get; set; } = new(); + [ForeignKey("EducationGroupId")] + public virtual List 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 + }; + + } +} diff --git a/UniversityDataBaseImplemet/Models/EducationGroupDocument.cs b/UniversityDataBaseImplemet/Models/EducationGroupDocument.cs new file mode 100644 index 0000000..fc64da7 --- /dev/null +++ b/UniversityDataBaseImplemet/Models/EducationGroupDocument.cs @@ -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(); + } +} diff --git a/UniversityDataBaseImplemet/Models/EducationGroupStream.cs b/UniversityDataBaseImplemet/Models/EducationGroupStream.cs new file mode 100644 index 0000000..cc7afca --- /dev/null +++ b/UniversityDataBaseImplemet/Models/EducationGroupStream.cs @@ -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(); + } +} diff --git a/UniversityDataBaseImplemet/Models/EducationStatus.cs b/UniversityDataBaseImplemet/Models/EducationStatus.cs index 06aff6a..d71c06d 100644 --- a/UniversityDataBaseImplemet/Models/EducationStatus.cs +++ b/UniversityDataBaseImplemet/Models/EducationStatus.cs @@ -20,7 +20,7 @@ namespace UniversityDataBaseImplemet.Models public int UserId { get; set; } [ForeignKey("EducationStatusId")] public virtual List Students { get; set; } = new(); - public virtual EducationStatus User { get; set; } + public virtual User User { get; set; } public static EducationStatus? Create(EducationStatusBindingModel model) { diff --git a/UniversityDataBaseImplemet/Models/Stream.cs b/UniversityDataBaseImplemet/Models/Stream.cs new file mode 100644 index 0000000..0781469 --- /dev/null +++ b/UniversityDataBaseImplemet/Models/Stream.cs @@ -0,0 +1,51 @@ +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 { get; set; } = new(); + [ForeignKey("StreamId")] + public virtual List StreamStudents { get; set; } = new(); + public virtual User User { get; set; } + + 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 StreamViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + UserId = UserId, + Course= Course + }; + } +} diff --git a/UniversityDataBaseImplemet/Models/Student.cs b/UniversityDataBaseImplemet/Models/Student.cs index 2182206..f064152 100644 --- a/UniversityDataBaseImplemet/Models/Student.cs +++ b/UniversityDataBaseImplemet/Models/Student.cs @@ -28,8 +28,10 @@ namespace UniversityDataBaseImplemet.Models public int UserId { get; set; } [ForeignKey("StudentId")] public virtual List DocumentStudents { get; set; } = new(); + [ForeignKey("StudentId")] + public virtual List StudentStream { get; set; } = new(); public virtual EducationStatus EducationStatus { get; set; } - public virtual EducationStatus User { get; set; } + public virtual User User { get; set; } public static Student Create(StudentBindingModel model) { diff --git a/UniversityDataBaseImplemet/Models/StudentStream.cs b/UniversityDataBaseImplemet/Models/StudentStream.cs new file mode 100644 index 0000000..6cbcec3 --- /dev/null +++ b/UniversityDataBaseImplemet/Models/StudentStream.cs @@ -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(); + } +} diff --git a/UniversityDataBaseImplemet/Models/User.cs b/UniversityDataBaseImplemet/Models/User.cs index 6d1eac2..e6141df 100644 --- a/UniversityDataBaseImplemet/Models/User.cs +++ b/UniversityDataBaseImplemet/Models/User.cs @@ -7,10 +7,11 @@ using System.Text; using System.Threading.Tasks; using UniversityContracts.BindingModels; using UniversityContracts.ViewModels; +using UniversityModels.Models; namespace UniversityDataBaseImplemet.Models { - public class User + public class User : IUserModel { public int Id { get; private set; } [Required] diff --git a/UniversityModels/Models/IDisciplineModel.cs b/UniversityModels/Models/IDisciplineModel.cs new file mode 100644 index 0000000..a16001c --- /dev/null +++ b/UniversityModels/Models/IDisciplineModel.cs @@ -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; } + } +} diff --git a/UniversityModels/Models/IEducationGroupModel.cs b/UniversityModels/Models/IEducationGroupModel.cs new file mode 100644 index 0000000..689e286 --- /dev/null +++ b/UniversityModels/Models/IEducationGroupModel.cs @@ -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;} + } +} diff --git a/UniversityModels/Models/IStreamModel.cs b/UniversityModels/Models/IStreamModel.cs new file mode 100644 index 0000000..4a69809 --- /dev/null +++ b/UniversityModels/Models/IStreamModel.cs @@ -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 IStreamModel:IId + { + string Name { get; } + int Course { get; } + int UserId { get; } + } +}