entity customer added #4
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("Дисциплина с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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("Статус с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
20
UniversityContracts/BindingModels/StreamBindingModel.cs
Normal file
20
UniversityContracts/BindingModels/StreamBindingModel.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 StreamBindingModel : IStreamModel
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public int Course { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public int Id { 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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
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);
|
||||
}
|
||||
}
|
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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
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; }
|
||||
}
|
||||
}
|
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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
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);
|
||||
}
|
||||
}
|
22
UniversityContracts/ViewModels/DisciplineViewModel.cs
Normal file
22
UniversityContracts/ViewModels/DisciplineViewModel.cs
Normal file
@ -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 уточнить
|
||||
}
|
||||
}
|
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; }
|
||||
}
|
||||
}
|
19
UniversityContracts/ViewModels/StreamViewModel.cs
Normal file
19
UniversityContracts/ViewModels/StreamViewModel.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 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; }
|
||||
}
|
||||
}
|
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
|
||||
};
|
||||
}
|
||||
}
|
@ -22,7 +22,9 @@ namespace UniversityDataBaseImplemet.Models
|
||||
public int UserId { get; set; }
|
||||
[ForeignKey("DocumentId")]
|
||||
public virtual List<StudentDocument> Students { get; set; } = new();
|
||||
public virtual EducationStatus User { get; set; }
|
||||
[ForeignKey("DocumentId")]
|
||||
public virtual List<EducationGroupDocument> EducationGroupDocument { get; set; } = new();
|
||||
public virtual User User { get; set; }
|
||||
|
||||
public static Document? Create(DocumentBindingModel model)
|
||||
{
|
||||
|
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();
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ namespace UniversityDataBaseImplemet.Models
|
||||
public int UserId { get; set; }
|
||||
[ForeignKey("EducationStatusId")]
|
||||
public virtual List<Student> Students { get; set; } = new();
|
||||
public virtual EducationStatus User { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
|
||||
public static EducationStatus? Create(EducationStatusBindingModel model)
|
||||
{
|
||||
|
51
UniversityDataBaseImplemet/Models/Stream.cs
Normal file
51
UniversityDataBaseImplemet/Models/Stream.cs
Normal file
@ -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> EducationGroupStream { get; set; } = new();
|
||||
[ForeignKey("StreamId")]
|
||||
public virtual List<StudentStream> 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
|
||||
};
|
||||
}
|
||||
}
|
@ -28,8 +28,10 @@ namespace UniversityDataBaseImplemet.Models
|
||||
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 EducationStatus User { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
|
||||
public static Student Create(StudentBindingModel model)
|
||||
{
|
||||
|
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();
|
||||
}
|
||||
}
|
@ -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]
|
||||
|
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; }
|
||||
}
|
||||
}
|
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;}
|
||||
}
|
||||
}
|
15
UniversityModels/Models/IStreamModel.cs
Normal file
15
UniversityModels/Models/IStreamModel.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 IStreamModel:IId
|
||||
{
|
||||
string Name { get; }
|
||||
int Course { get; }
|
||||
int UserId { get; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user