Удалены Worker и Storekeeper, вместо них UserModel. Плюс удаление миграции и необходима новая логика базы данных.
This commit is contained in:
parent
85223abfaf
commit
8d7f335c9e
@ -127,13 +127,17 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Не выбрана форма оценивания", nameof(model.FormOfEvaluation));
|
||||
}
|
||||
if (model.UserId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор пользователя", nameof(model.UserId));
|
||||
}
|
||||
|
||||
if (model.StudentId <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор студента", nameof(model.StudentId));
|
||||
}
|
||||
_logger.LogInformation("Attestation. AttestationId:{Id}.FormOfEvaluation:{FormOfEvaluation}. StudentId: { StudentId}",
|
||||
model.Id, model.FormOfEvaluation, model.StudentId);
|
||||
_logger.LogInformation("Attestation. AttestationId:{Id}.FormOfEvaluation:{FormOfEvaluation}. StudentId: {StudentId}. UserId: {UserId}",
|
||||
model.Id, model.FormOfEvaluation, model.StudentId, model.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +97,12 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Должна быть дисциплина", nameof(model.Description));
|
||||
}
|
||||
_logger.LogInformation("Discipline. Name:{Name}.Description:{Description}. Id: {Id}",
|
||||
model.Name, model.Description, model.Id);
|
||||
if (model.UserId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор пользователя", nameof(model.UserId));
|
||||
}
|
||||
_logger.LogInformation("Discipline. Name:{Name}.Description:{Description}. UserId: {UserId}. Id: {Id}",
|
||||
model.Name, model.Description, model.UserId, model.Id);
|
||||
var element = _disciplineStorage.GetElement(new DisciplineSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
|
@ -103,8 +103,12 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Не указана форма обучения", nameof(model.FormOfStudy));
|
||||
}
|
||||
_logger.LogInformation("Student. Profile:{Profile}.FormOfStudy:{FormOfStudy}. Id: {Id}",
|
||||
model.Profile, model.FormOfStudy, model.Id);
|
||||
if (model.UserId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор пользователя", nameof(model.UserId));
|
||||
}
|
||||
_logger.LogInformation("Student. Profile:{Profile}.FormOfStudy:{FormOfStudy}. UserId: {UserId}. Id: {Id}",
|
||||
model.Profile, model.FormOfStudy, model.UserId, model.Id);
|
||||
var element = _planOfStudyStorage.GetElement(new PlanOfStudySearchModel
|
||||
{
|
||||
Profile = model.Profile
|
||||
|
@ -107,8 +107,12 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор преподавателя", nameof(model.TeacherId));
|
||||
}
|
||||
_logger.LogInformation("Statement. StatementId:{Id}.Name:{Name}. TeacherId: { TeacherId}",
|
||||
model.Id, model.Name, model.TeacherId);
|
||||
if (model.UserId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор пользователя", nameof(model.UserId));
|
||||
}
|
||||
_logger.LogInformation("Statement. StatementId:{Id}.Name:{Name}. TeacherId: {TeacherId}. UserId: {UserId}",
|
||||
model.Id, model.Name, model.TeacherId, model.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,8 +98,12 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Должен быть номер телефона", nameof(model.PhoneNumber));
|
||||
}
|
||||
_logger.LogInformation("Student. Name:{Name}.PhoneNumber:{PhoneNumber}. Id: {Id}",
|
||||
model.Name, model.PhoneNumber, model.Id);
|
||||
if (model.UserId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор пользователя", nameof(model.UserId));
|
||||
}
|
||||
_logger.LogInformation("Student. Name:{Name}.PhoneNumber:{PhoneNumber}. UserId: {UserId}. Id: {Id}",
|
||||
model.Name, model.PhoneNumber, model.UserId, model.Id);
|
||||
var element = _studentStorage.GetElement(new StudentSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
|
@ -108,8 +108,12 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Нет должности",
|
||||
nameof(model.Position));
|
||||
}
|
||||
_logger.LogInformation("Teacher. Name:{Name}.AcademicDegree:{AcademicDegree}. Position:{Position}. Id: {Id}",
|
||||
model.Name, model.AcademicDegree, model.Position, model.Id);
|
||||
if (model.UserId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор пользователя", nameof(model.UserId));
|
||||
}
|
||||
_logger.LogInformation("Teacher. Name:{Name}.AcademicDegree:{AcademicDegree}. Position:{Position}. UserId: {UserId}. Id: {Id}",
|
||||
model.Name, model.AcademicDegree, model.Position, model.UserId, model.Id);
|
||||
var element = _teacherStorage.GetElement(new TeacherSearchModel
|
||||
{
|
||||
Name = model.Name
|
||||
|
131
University/UniversityBusinessLogic/BusinessLogics/UserLogic.cs
Normal file
131
University/UniversityBusinessLogic/BusinessLogics/UserLogic.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicsContracts;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StorageContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDataModels.Enums;
|
||||
|
||||
namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class UserLogic : IUserLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUserStorage _userStorage;
|
||||
|
||||
public UserLogic(ILogger<IUserLogic> logger, IUserStorage userStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_userStorage = userStorage;
|
||||
}
|
||||
public List<UserViewModel>? ReadList(UserSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("User ReadList. Login:{Login} Emain:{Email} Id:{Id}", model?.Login, model?.Email, model?.Id);
|
||||
var list = model == null ? _userStorage.GetFullList() : _userStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public UserViewModel? ReadElement(UserSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Login:{Login}. Email:{Email}. Id:{Id}", model?.Login, model?.Email, model?.Id);
|
||||
var element = _userStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(UserBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_userStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(UserBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_userStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(UserBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_userStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
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));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Нет почты пользователя", nameof(model.Email));
|
||||
}
|
||||
var user1 = _userStorage.GetElement(new UserSearchModel
|
||||
{
|
||||
Login = model.Login
|
||||
});
|
||||
|
||||
if (user1 != null && user1.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Пользователь с таким логином уже есть");
|
||||
}
|
||||
var user2 = _userStorage.GetElement(new UserSearchModel
|
||||
{
|
||||
Email = model.Email
|
||||
});
|
||||
|
||||
if (user2 != null && user2.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Пользователь с такой почтой уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicsContracts;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StorageContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDataModels.Enums;
|
||||
|
||||
namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkerLogic : IWorkerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkerStorage _workerStorage;
|
||||
public WorkerLogic(ILogger<WorkerLogic> logger, IWorkerStorage
|
||||
workerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_workerStorage = workerStorage;
|
||||
}
|
||||
public List<WorkerViewModel>? ReadList(WorkerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. FirstName: {FirstName}.LastName: {LastName}. PhoneNumber: {PhoneNumber}" +
|
||||
"Email: {Email}.Id:{Id} ",
|
||||
model?.FirstName, model?.LastName, model?.PhoneNumber, model?.Email, model?.Id);
|
||||
var list = model == null ? _workerStorage.GetFullList() :
|
||||
_workerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public WorkerViewModel? ReadElement(WorkerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadList. FirstName: {FirstName}.LastName: {LastName}. PhoneNumber: {PhoneNumber}" +
|
||||
"Email: {Email}.Id:{Id} ",
|
||||
model?.FirstName, model?.LastName, model?.PhoneNumber, model?.Email, model?.Id);
|
||||
var element = _workerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(WorkerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_workerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(WorkerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_workerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(WorkerBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_workerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(WorkerBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.FirstName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет имени пользователя",
|
||||
nameof(model.FirstName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.LastName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет фамилии пользователя",
|
||||
nameof(model.LastName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Должен быть номер телефона", nameof(model.PhoneNumber));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Не указана почта",
|
||||
nameof(model.Email));
|
||||
}
|
||||
_logger.LogInformation("Worker. FirstName: {FirstName}.LastName: {LastName}. PhoneNumber: " +
|
||||
"{PhoneNumber}.Email: {Email}.Id:{Id}",
|
||||
model.FirstName, model.LastName, model.PhoneNumber, model.Email, model.Id);
|
||||
var element = _workerStorage.GetElement(new WorkerSearchModel
|
||||
{
|
||||
FirstName = model.FirstName,
|
||||
LastName = model.LastName,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Email = model.Email
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Данный пользователь уже существует");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ namespace UniversityContracts.BindingModels
|
||||
public class AttestationBindingModel : IAttestationModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string FormOfEvaluation { get; set; } = string.Empty;
|
||||
public AttestationScore Score { get; set; } = AttestationScore.Неявка;
|
||||
public int StudentId { get; set; }
|
||||
|
@ -11,6 +11,7 @@ namespace UniversityContracts.BindingModels
|
||||
public class DisciplineBindingModel : IDisciplineModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int TeacherId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
@ -10,6 +10,7 @@ namespace UniversityContracts.BindingModels
|
||||
public class PlanOfStudyBindingModel : IPlanOfStudyModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string Profile { get; set; } = string.Empty;
|
||||
public string FormOfStudy { get; set; } = string.Empty;
|
||||
public int WorkerId { get; set; }
|
||||
|
@ -11,6 +11,7 @@ namespace UniversityContracts.BindingModels
|
||||
public class StatementBindingModel : IStatementModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int TeacherId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public DateTime Date { get; }
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityContracts.BindingModels
|
||||
{
|
||||
public class StorekeeperBindingModel : IStorekeeperModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
public string MiddleName { get; set; } = string.Empty;
|
||||
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ namespace UniversityContracts.BindingModels
|
||||
public class StudentBindingModel : IStudentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int PlanOfStudyId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
@ -11,6 +11,7 @@ namespace UniversityContracts.BindingModels
|
||||
public class TeacherBindingModel : ITeacherModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int StorekeeperId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string AcademicDegree { get; set; } = string.Empty;
|
||||
|
@ -3,17 +3,17 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.Enums;
|
||||
using UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityContracts.BindingModels
|
||||
{
|
||||
public class WorkerBindingModel : IWorkerModel
|
||||
public class UserBindingModel : IUserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string MiddleName { get; set; } = string.Empty;
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
public string Login { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public UserRole Role { get; set; } = UserRole.Неизвестная;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
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.BusinessLogicsContracts
|
||||
{
|
||||
public interface IStorekeeperLogic
|
||||
{
|
||||
List<StorekeeperViewModel>? ReadList(StorekeeperSearchModel? model);
|
||||
StorekeeperViewModel? ReadElement(StorekeeperSearchModel model);
|
||||
bool Create(StorekeeperBindingModel model);
|
||||
bool Update(StorekeeperBindingModel model);
|
||||
bool Delete(StorekeeperBindingModel model);
|
||||
}
|
||||
}
|
@ -9,12 +9,12 @@ using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkerLogic
|
||||
public interface IUserLogic
|
||||
{
|
||||
List<WorkerViewModel>? ReadList(WorkerSearchModel? model);
|
||||
WorkerViewModel? ReadElement(WorkerSearchModel model);
|
||||
bool Create(WorkerBindingModel model);
|
||||
bool Update(WorkerBindingModel model);
|
||||
bool Delete(WorkerBindingModel model);
|
||||
List<UserViewModel>? ReadList(UserSearchModel? model);
|
||||
UserViewModel? ReadElement(UserSearchModel model);
|
||||
bool Create(UserBindingModel model);
|
||||
bool Update(UserBindingModel model);
|
||||
bool Delete(UserBindingModel model);
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace UniversityContracts.SearchModels
|
||||
public class AttestationSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int? StudentId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace UniversityContracts.SearchModels
|
||||
public class DisciplineSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int? TeacherId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
@ -9,6 +9,7 @@ namespace UniversityContracts.SearchModels
|
||||
public class PlanOfStudySearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string? Profile { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace UniversityContracts.SearchModels
|
||||
public class StatementSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels;
|
||||
using UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityContracts.SearchModels
|
||||
{
|
||||
public class StorekeeperSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
|
||||
public string? LastName { get; set; }
|
||||
|
||||
public string? MiddleName { get; set; }
|
||||
|
||||
public string? PhoneNumber { get; set; }
|
||||
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ namespace UniversityContracts.SearchModels
|
||||
public class StudentSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace UniversityContracts.SearchModels
|
||||
public class TeacherSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? AcademicDegree { get; set; }
|
||||
public string? Position { get; set; }
|
||||
|
@ -3,15 +3,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.Enums;
|
||||
|
||||
namespace UniversityContracts.SearchModels
|
||||
{
|
||||
public class WorkerSearchModel
|
||||
public class UserSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? Login { get; set; }
|
||||
|
||||
public string? Password { get; set; }
|
||||
|
||||
public string? Email { get; set; }
|
||||
public UserRole? Role { get; set; }
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
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.StorageContracts
|
||||
{
|
||||
public interface IStorekeeperStorage
|
||||
{
|
||||
List<StorekeeperViewModel> GetFullList();
|
||||
List<StorekeeperViewModel> GetFilteredList(StorekeeperSearchModel model);
|
||||
StorekeeperViewModel? GetElement(StorekeeperSearchModel model);
|
||||
StorekeeperViewModel? Insert(StorekeeperBindingModel model);
|
||||
StorekeeperViewModel? Update(StorekeeperBindingModel model);
|
||||
StorekeeperViewModel? Delete(StorekeeperBindingModel 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.StorageContracts
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
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.StorageContracts
|
||||
{
|
||||
public interface IWorkerStorage
|
||||
{
|
||||
List<WorkerViewModel> GetFullList();
|
||||
List<WorkerViewModel> GetFilteredList(WorkerSearchModel model);
|
||||
WorkerViewModel? GetElement(WorkerSearchModel model);
|
||||
WorkerViewModel? Insert(WorkerBindingModel model);
|
||||
WorkerViewModel? Update(WorkerBindingModel model);
|
||||
WorkerViewModel? Delete(WorkerBindingModel model);
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ namespace UniversityContracts.ViewModels
|
||||
public class AttestationViewModel : IAttestationModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int StudentId { get; set; }
|
||||
[DisplayName("Форма оценивания")]
|
||||
public string FormOfEvaluation { get; set; } = string.Empty;
|
||||
|
@ -11,6 +11,7 @@ namespace UniversityContracts.ViewModels
|
||||
public class DisciplineViewModel : IDisciplineModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int TeacherId { get; set; }
|
||||
[DisplayName("Название дисциплины")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
@ -11,6 +11,7 @@ namespace UniversityContracts.ViewModels
|
||||
public class PlanOfStudyViewModel : IPlanOfStudyModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int WorkerId { get; set; }
|
||||
[DisplayName("Профиль")]
|
||||
public string Profile { get; set; } = string.Empty;
|
||||
|
@ -11,6 +11,7 @@ namespace UniversityContracts.ViewModels
|
||||
public class StatementViewModel : IStatementModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int TeacherId { get; set; }
|
||||
[DisplayName("Название ведомости")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class StorekeeperViewModel : IStorekeeperModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя")]
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
[DisplayName("Фамилия")]
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
[DisplayName("Отчество")]
|
||||
public string MiddleName { get; set; } = string.Empty;
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ namespace UniversityContracts.ViewModels
|
||||
public class StudentViewModel : IStudentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int PlanOfStudyId { get; set; }
|
||||
[DisplayName("ФИО")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
@ -11,6 +11,7 @@ namespace UniversityContracts.ViewModels
|
||||
public class TeacherViewModel : ITeacherModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int StorekeeperId { get; set; }
|
||||
[DisplayName("ФИО")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
25
University/UniversityContracts/ViewModels/UserViewModel.cs
Normal file
25
University/UniversityContracts/ViewModels/UserViewModel.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.Enums;
|
||||
using UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class UserViewModel : IUserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Логин")]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public UserRole Role { get; set; }
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class WorkerViewModel : IWorkerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя")]
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
[DisplayName("Фамилия")]
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
[DisplayName("Отчество")]
|
||||
public string MiddleName { get; set; } = string.Empty;
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
17
University/UniversityDataModels/Enums/UserRole.cs
Normal file
17
University/UniversityDataModels/Enums/UserRole.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityDataModels.Enums
|
||||
{
|
||||
public enum UserRole
|
||||
{
|
||||
Неизвестная = -1,
|
||||
|
||||
Работник = 0,
|
||||
|
||||
Кладовщик = 1
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace UniversityDataModels
|
||||
{
|
||||
public interface IPerson : IId
|
||||
{
|
||||
public string FirstName { get; }
|
||||
|
||||
public string LastName { get; }
|
||||
|
||||
public string MiddleName { get; }
|
||||
|
||||
public string PhoneNumber { get; }
|
||||
|
||||
public string Email { get; }
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ namespace UniversityDataModels.Models
|
||||
{
|
||||
public interface IAttestationModel : IId
|
||||
{
|
||||
int UserId { get; }
|
||||
string FormOfEvaluation { get; }
|
||||
AttestationScore Score { get; }
|
||||
int StudentId { get; }
|
||||
|
@ -2,6 +2,7 @@
|
||||
{
|
||||
public interface IDisciplineModel : IId
|
||||
{
|
||||
int UserId { get; }
|
||||
int TeacherId { get; }
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
|
@ -2,8 +2,8 @@
|
||||
{
|
||||
public interface IPlanOfStudyModel : IId
|
||||
{
|
||||
int UserId { get; }
|
||||
string Profile { get; }
|
||||
string FormOfStudy { get; }
|
||||
int WorkerId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
{
|
||||
public interface IStatementModel : IId
|
||||
{
|
||||
int UserId { get; }
|
||||
int TeacherId { get; }
|
||||
string Name { get; }
|
||||
DateTime Date { get; }
|
||||
|
@ -1,6 +0,0 @@
|
||||
namespace UniversityDataModels.Models
|
||||
{
|
||||
public interface IStorekeeperModel : IPerson
|
||||
{
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
{
|
||||
public interface IStudentModel : IId
|
||||
{
|
||||
int UserId { get; }
|
||||
string Name { get; }
|
||||
string PhoneNumber { get; }
|
||||
int PlanOfStudyId { get; }
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
public interface ITeacherModel : IId
|
||||
{
|
||||
int StorekeeperId { get; }
|
||||
int UserId { get; }
|
||||
string Name { get; }
|
||||
string AcademicDegree { get; }
|
||||
string Position { get; }
|
||||
|
18
University/UniversityDataModels/Models/IUserModel.cs
Normal file
18
University/UniversityDataModels/Models/IUserModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.Enums;
|
||||
|
||||
namespace UniversityDataModels.Models
|
||||
{
|
||||
public interface IUserModel : IId
|
||||
{
|
||||
public string Login { get; }
|
||||
public string Password { get; }
|
||||
|
||||
public string Email { get; }
|
||||
public UserRole Role { get; }
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace UniversityDataModels.Models
|
||||
{
|
||||
public interface IWorkerModel : IPerson
|
||||
{
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StorageContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDatabaseImplement.Models;
|
||||
using UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
public class StorekeeperStorage: IStorekeeperStorage
|
||||
{
|
||||
public StorekeeperViewModel? GetElement(StorekeeperSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
return context.Storekeepers.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Email) && x.Email == model.Email)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<StorekeeperViewModel> GetFilteredList(StorekeeperSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
return context.Storekeepers
|
||||
.Where(x => x.Email.Contains(model.Email))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<StorekeeperViewModel> GetFullList()
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
return context.Storekeepers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public StorekeeperViewModel? Insert(StorekeeperBindingModel model)
|
||||
{
|
||||
var newStorekeeper = Storekeeper.Create(model);
|
||||
if (newStorekeeper == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
context.Storekeepers.Add(newStorekeeper);
|
||||
context.SaveChanges();
|
||||
return newStorekeeper.GetViewModel;
|
||||
}
|
||||
|
||||
public StorekeeperViewModel? Update(StorekeeperBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
var client = context.Storekeepers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
public StorekeeperViewModel? Delete(StorekeeperBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
var client = context.Storekeepers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Storekeepers.Remove(client);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ namespace UniversityDatabaseImplement.Implements
|
||||
.Where(x => x.Name.Contains(model.Name))
|
||||
.Where(x => x.Position.Contains(model.Position))
|
||||
.Where(x => x.AcademicDegree.Contains(model.AcademicDegree))
|
||||
.Include(x => x.Storekeeper)
|
||||
.Include(x => x.User)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StorageContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDatabaseImplement.Models;
|
||||
using UniversityDataModels.Enums;
|
||||
|
||||
namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
public class UserStorage : IUserStorage
|
||||
{
|
||||
public List<UserViewModel> GetFullList()
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
return context.Users.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<UserViewModel> GetFilteredList(UserSearchModel model)
|
||||
{
|
||||
if (model.Role == null || model.Role == UserRole.Неизвестная)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
return context.Users.Where(x => x.Role == model.Role).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public UserViewModel? GetElement(UserSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
|
||||
//Поиск пользователя при входе в систему по логину, паролю и его роли (чтобы не могли войти в аккаунты другой роли)
|
||||
if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password) && model.Role.HasValue)
|
||||
{
|
||||
return context.Users.FirstOrDefault(x => x.Login == model.Login && x.Password == model.Password && x.Role == model.Role)?.GetViewModel;
|
||||
}
|
||||
//Получение по логину (пользователей с таким логином будет 1 или 0)
|
||||
if (!string.IsNullOrEmpty(model.Login))
|
||||
{
|
||||
return context.Users.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
||||
}
|
||||
//Получение по почте (пользователей с такой почтой будет 1 или 0)
|
||||
else if (!string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return context.Users.FirstOrDefault(x => x.Email == model.Email)?.GetViewModel;
|
||||
}
|
||||
//Получение по id
|
||||
return context.Users.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public UserViewModel? Insert(UserBindingModel model)
|
||||
{
|
||||
var newUser = User.Create(model);
|
||||
if (newUser == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
context.Users.Add(newUser);
|
||||
context.SaveChanges();
|
||||
return newUser.GetViewModel;
|
||||
}
|
||||
|
||||
public UserViewModel? Update(UserBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
var user = context.Users.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (user == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
user.Update(model);
|
||||
context.SaveChanges();
|
||||
return user.GetViewModel;
|
||||
}
|
||||
public UserViewModel? Delete(UserBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
var user = context.Users.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (user != null)
|
||||
{
|
||||
context.Users.Remove(user);
|
||||
context.SaveChanges();
|
||||
return user.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StorageContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDatabaseImplement.Models;
|
||||
|
||||
namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
public class WorkerStorage : IWorkerStorage
|
||||
{
|
||||
public WorkerViewModel? GetElement(WorkerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
|
||||
return context.Workers.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Email) && x.Email == model.Email)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
return context.Workers
|
||||
.Where(x => x.Email.Contains(model.Email))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<WorkerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
return context.Workers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public WorkerViewModel? Insert(WorkerBindingModel model)
|
||||
{
|
||||
var newWorker = Worker.Create(model);
|
||||
if (newWorker == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new UniversityDatabase();
|
||||
context.Workers.Add(newWorker);
|
||||
context.SaveChanges();
|
||||
return newWorker.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkerViewModel? Update(WorkerBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
var client = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
public WorkerViewModel? Delete(WorkerBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
var client = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Workers.Remove(client);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,442 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using UniversityDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(UniversityDatabase))]
|
||||
[Migration("20240429094924_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Attestation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FormOfEvaluation")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Score")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("Attestations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.ToTable("Disciplines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FormOfStudy")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Profile")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("WorkerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorkerId");
|
||||
|
||||
b.ToTable("PlanOfStudys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudyTeacher", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("PlanOfStudyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlanOfStudyId");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.ToTable("PlanOfStudyTeachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.ToTable("Statements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Storekeeper", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Storekeepers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PlanOfStudyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlanOfStudyId");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentDiscipline", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DisciplineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DisciplineId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("StudentDisciplines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AcademicDegree")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Position")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("StorekeeperId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StorekeeperId");
|
||||
|
||||
b.ToTable("Teachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Workers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Attestation", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
|
||||
.WithMany("Attestations")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("Disciplines")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Teacher");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Worker", "Worker")
|
||||
.WithMany("PlanOfStudys")
|
||||
.HasForeignKey("WorkerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Worker");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudyTeacher", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.PlanOfStudy", "PlanOfStudy")
|
||||
.WithMany("Teachers")
|
||||
.HasForeignKey("PlanOfStudyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("PlanOfStudyTeachers")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PlanOfStudy");
|
||||
|
||||
b.Navigation("Teacher");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("Statements")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Teacher");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.PlanOfStudy", "PlanOfStudy")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("PlanOfStudyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PlanOfStudy");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentDiscipline", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("DisciplineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
|
||||
.WithMany("StudentDiscipline")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Discipline");
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Storekeeper", "Storekeeper")
|
||||
.WithMany("Teachers")
|
||||
.HasForeignKey("StorekeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Storekeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.Navigation("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.Navigation("Students");
|
||||
|
||||
b.Navigation("Teachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Storekeeper", b =>
|
||||
{
|
||||
b.Navigation("Teachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.Navigation("Attestations");
|
||||
|
||||
b.Navigation("StudentDiscipline");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.Navigation("Disciplines");
|
||||
|
||||
b.Navigation("PlanOfStudyTeachers");
|
||||
|
||||
b.Navigation("Statements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Navigation("PlanOfStudys");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,312 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Storekeepers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Storekeepers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Workers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
MiddleName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Workers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Teachers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
StorekeeperId = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
AcademicDegree = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Position = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Teachers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Teachers_Storekeepers_StorekeeperId",
|
||||
column: x => x.StorekeeperId,
|
||||
principalTable: "Storekeepers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlanOfStudys",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkerId = table.Column<int>(type: "int", nullable: false),
|
||||
Profile = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
FormOfStudy = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PlanOfStudys", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PlanOfStudys_Workers_WorkerId",
|
||||
column: x => x.WorkerId,
|
||||
principalTable: "Workers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Disciplines",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TeacherId = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Disciplines", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Disciplines_Teachers_TeacherId",
|
||||
column: x => x.TeacherId,
|
||||
principalTable: "Teachers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Statements",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TeacherId = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Statements", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Statements_Teachers_TeacherId",
|
||||
column: x => x.TeacherId,
|
||||
principalTable: "Teachers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlanOfStudyTeachers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PlanOfStudyId = table.Column<int>(type: "int", nullable: false),
|
||||
TeacherId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PlanOfStudyTeachers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PlanOfStudyTeachers_PlanOfStudys_PlanOfStudyId",
|
||||
column: x => x.PlanOfStudyId,
|
||||
principalTable: "PlanOfStudys",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PlanOfStudyTeachers_Teachers_TeacherId",
|
||||
column: x => x.TeacherId,
|
||||
principalTable: "Teachers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Students",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PlanOfStudyId = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Students", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Students_PlanOfStudys_PlanOfStudyId",
|
||||
column: x => x.PlanOfStudyId,
|
||||
principalTable: "PlanOfStudys",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Attestations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
StudentId = table.Column<int>(type: "int", nullable: false),
|
||||
FormOfEvaluation = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Score = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Attestations", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Attestations_Students_StudentId",
|
||||
column: x => x.StudentId,
|
||||
principalTable: "Students",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "StudentDisciplines",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
StudentId = table.Column<int>(type: "int", nullable: false),
|
||||
DisciplineId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_StudentDisciplines", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_StudentDisciplines_Disciplines_DisciplineId",
|
||||
column: x => x.DisciplineId,
|
||||
principalTable: "Disciplines",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_StudentDisciplines_Students_StudentId",
|
||||
column: x => x.StudentId,
|
||||
principalTable: "Students",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Attestations_StudentId",
|
||||
table: "Attestations",
|
||||
column: "StudentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Disciplines_TeacherId",
|
||||
table: "Disciplines",
|
||||
column: "TeacherId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PlanOfStudys_WorkerId",
|
||||
table: "PlanOfStudys",
|
||||
column: "WorkerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PlanOfStudyTeachers_PlanOfStudyId",
|
||||
table: "PlanOfStudyTeachers",
|
||||
column: "PlanOfStudyId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PlanOfStudyTeachers_TeacherId",
|
||||
table: "PlanOfStudyTeachers",
|
||||
column: "TeacherId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Statements_TeacherId",
|
||||
table: "Statements",
|
||||
column: "TeacherId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_StudentDisciplines_DisciplineId",
|
||||
table: "StudentDisciplines",
|
||||
column: "DisciplineId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_StudentDisciplines_StudentId",
|
||||
table: "StudentDisciplines",
|
||||
column: "StudentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Students_PlanOfStudyId",
|
||||
table: "Students",
|
||||
column: "PlanOfStudyId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Teachers_StorekeeperId",
|
||||
table: "Teachers",
|
||||
column: "StorekeeperId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Attestations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PlanOfStudyTeachers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Statements");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "StudentDisciplines");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Disciplines");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Students");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Teachers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PlanOfStudys");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Storekeepers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Workers");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,439 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using UniversityDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(UniversityDatabase))]
|
||||
partial class UniversityDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Attestation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FormOfEvaluation")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Score")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("Attestations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.ToTable("Disciplines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FormOfStudy")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Profile")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("WorkerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorkerId");
|
||||
|
||||
b.ToTable("PlanOfStudys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudyTeacher", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("PlanOfStudyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlanOfStudyId");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.ToTable("PlanOfStudyTeachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.ToTable("Statements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Storekeeper", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Storekeepers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PlanOfStudyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlanOfStudyId");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentDiscipline", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DisciplineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DisciplineId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("StudentDisciplines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AcademicDegree")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Position")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("StorekeeperId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StorekeeperId");
|
||||
|
||||
b.ToTable("Teachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Workers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Attestation", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
|
||||
.WithMany("Attestations")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("Disciplines")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Teacher");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Worker", "Worker")
|
||||
.WithMany("PlanOfStudys")
|
||||
.HasForeignKey("WorkerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Worker");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudyTeacher", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.PlanOfStudy", "PlanOfStudy")
|
||||
.WithMany("Teachers")
|
||||
.HasForeignKey("PlanOfStudyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("PlanOfStudyTeachers")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PlanOfStudy");
|
||||
|
||||
b.Navigation("Teacher");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("Statements")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Teacher");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.PlanOfStudy", "PlanOfStudy")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("PlanOfStudyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PlanOfStudy");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentDiscipline", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("DisciplineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
|
||||
.WithMany("StudentDiscipline")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Discipline");
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Storekeeper", "Storekeeper")
|
||||
.WithMany("Teachers")
|
||||
.HasForeignKey("StorekeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Storekeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.Navigation("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.Navigation("Students");
|
||||
|
||||
b.Navigation("Teachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Storekeeper", b =>
|
||||
{
|
||||
b.Navigation("Teachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.Navigation("Attestations");
|
||||
|
||||
b.Navigation("StudentDiscipline");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.Navigation("Disciplines");
|
||||
|
||||
b.Navigation("PlanOfStudyTeachers");
|
||||
|
||||
b.Navigation("Statements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Navigation("PlanOfStudys");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
public class PlanOfStudy : IPlanOfStudyModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int WorkerId { get; private set; }
|
||||
public int UserId { get; private set; }
|
||||
[Required]
|
||||
public string Profile { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
@ -37,7 +37,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
public virtual List<PlanOfStudyTeacher> Teachers { get; set; } = new();
|
||||
[ForeignKey("PlanOfStudyId")]
|
||||
public virtual List<Student> Students { get; set; } = new();
|
||||
public virtual Worker Worker { get; set; } = new();
|
||||
public virtual User User { get; set; } = new();
|
||||
public static PlanOfStudy Create(UniversityDatabase context, PlanOfStudyBindingModel model)
|
||||
{
|
||||
return new PlanOfStudy()
|
||||
|
@ -1,83 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
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 UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
public class Storekeeper : IStorekeeperModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string FirstName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string LastName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string MiddleName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string PhoneNumber { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
[ForeignKey("StorekeeperId")]
|
||||
public virtual List<Teacher> Teachers { get; set; } = new();
|
||||
public static Storekeeper? Create(StorekeeperBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Storekeeper()
|
||||
{
|
||||
Id = model.Id,
|
||||
FirstName = model.FirstName,
|
||||
LastName = model.LastName,
|
||||
MiddleName = model.MiddleName,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Email = model.Email,
|
||||
|
||||
};
|
||||
}
|
||||
public static Storekeeper Create(StorekeeperViewModel model)
|
||||
{
|
||||
return new Storekeeper
|
||||
{
|
||||
Id = model.Id,
|
||||
FirstName = model.FirstName,
|
||||
LastName = model.LastName,
|
||||
MiddleName = model.MiddleName,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Email = model.Email,
|
||||
};
|
||||
}
|
||||
public void Update(StorekeeperBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
FirstName = model.FirstName;
|
||||
LastName = model.LastName;
|
||||
MiddleName = model.MiddleName;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
Email = model.Email;
|
||||
}
|
||||
public StorekeeperViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FirstName = FirstName,
|
||||
LastName = LastName,
|
||||
MiddleName = MiddleName,
|
||||
PhoneNumber = PhoneNumber,
|
||||
Email = Email,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -15,7 +15,8 @@ namespace UniversityDatabaseImplement.Models
|
||||
public class Student : IStudentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int PlanOfStudyId { get; private set; }
|
||||
public int UserId { get; private set; }
|
||||
public int? PlanOfStudyId { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
@ -25,26 +26,16 @@ namespace UniversityDatabaseImplement.Models
|
||||
[ForeignKey("StudentId")]
|
||||
public virtual List<Attestation> Attestations { get; set; } = new();
|
||||
public virtual PlanOfStudy PlanOfStudy { get; set; } = new();
|
||||
public static Student? Create(StudentBindingModel model)
|
||||
public virtual User User { get; set; } = new();
|
||||
public static Student? Create(UniversityDatabase context, StudentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Student()
|
||||
{
|
||||
Id = model.Id,
|
||||
UserId = model.UserId,
|
||||
User = context.Users.First(x => x.Id == model.UserId),
|
||||
PlanOfStudyId = model.PlanOfStudyId,
|
||||
Name = model.Name,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
}
|
||||
public static Student Create(StudentViewModel model)
|
||||
{
|
||||
return new Student
|
||||
{
|
||||
Id = model.Id,
|
||||
PlanOfStudyId = model.PlanOfStudyId,
|
||||
PlanOfStudy = model.PlanOfStudyId.HasValue ? context.PlanOfStudys.First(x => x.Id == model.PlanOfStudyId) : null,
|
||||
Name = model.Name,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
|
@ -16,14 +16,14 @@ namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int StorekeeperId { get; private set; }
|
||||
public int UserId { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string AcademicDegree { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Position { get; private set; } = string.Empty;
|
||||
public virtual Storekeeper Storekeeper { get; set; } = new ();
|
||||
public virtual User User { get; set; } = new ();
|
||||
[ForeignKey("TeacherId")]
|
||||
public virtual List<Statement> Statements { get; set; } = new();
|
||||
[ForeignKey("TeacherId")]
|
||||
@ -39,7 +39,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
return new Teacher()
|
||||
{
|
||||
Id = model.Id,
|
||||
StorekeeperId = model.StorekeeperId,
|
||||
UserId = model.UserId,
|
||||
Name = model.Name,
|
||||
AcademicDegree = model.AcademicDegree,
|
||||
Position = model.Position,
|
||||
@ -50,7 +50,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
return new Teacher()
|
||||
{
|
||||
Id = model.Id,
|
||||
StorekeeperId = model.StorekeeperId,
|
||||
UserId = model.UserId,
|
||||
Name = model.Name,
|
||||
AcademicDegree = model.AcademicDegree,
|
||||
Position = model.Position,
|
||||
@ -63,7 +63,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
StorekeeperId = model.StorekeeperId;
|
||||
UserId = model.UserId;
|
||||
Name = model.Name;
|
||||
AcademicDegree = model.AcademicDegree;
|
||||
Position = model.Position;
|
||||
@ -71,7 +71,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
public TeacherViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StorekeeperId = StorekeeperId,
|
||||
UserId = UserId,
|
||||
Name = Name,
|
||||
AcademicDegree = AcademicDegree,
|
||||
Position = Position,
|
||||
|
58
University/UniversityDatabaseImplement/Models/User.cs
Normal file
58
University/UniversityDatabaseImplement/Models/User.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 UniversityDataModels.Models;
|
||||
using UniversityDataModels.Enums;
|
||||
|
||||
namespace UniversityDatabaseImplement.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 string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public UserRole Role { get; set; }
|
||||
public static User Create(UserBindingModel model)
|
||||
{
|
||||
return new User
|
||||
{
|
||||
Id = model.Id,
|
||||
Login = model.Login,
|
||||
Password = model.Password,
|
||||
Email = model.Email
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(UserBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Login = model.Login;
|
||||
Password = model.Password;
|
||||
Email = model.Email;
|
||||
}
|
||||
public UserViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Login = Login,
|
||||
Password = Password,
|
||||
Email = Email,
|
||||
Role = Role
|
||||
};
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
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 UniversityDataModels.Models;
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
public class Worker : IWorkerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string FirstName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string LastName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string MiddleName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string PhoneNumber { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
[ForeignKey("WorkerId")]
|
||||
public virtual List<PlanOfStudy> PlanOfStudys { get; set; } = new();
|
||||
public static Worker? Create(WorkerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Worker()
|
||||
{
|
||||
Id = model.Id,
|
||||
FirstName = model.FirstName,
|
||||
LastName = model.LastName,
|
||||
MiddleName = model.MiddleName,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Email = model.Email,
|
||||
|
||||
};
|
||||
}
|
||||
public static Worker Create(WorkerViewModel model)
|
||||
{
|
||||
return new Worker
|
||||
{
|
||||
Id = model.Id,
|
||||
FirstName = model.FirstName,
|
||||
LastName = model.LastName,
|
||||
MiddleName = model.MiddleName,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Email = model.Email,
|
||||
};
|
||||
}
|
||||
public void Update(WorkerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
FirstName = model.FirstName;
|
||||
LastName = model.LastName;
|
||||
MiddleName = model.MiddleName;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
Email = model.Email;
|
||||
}
|
||||
public WorkerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FirstName = FirstName,
|
||||
LastName = LastName,
|
||||
MiddleName = MiddleName,
|
||||
PhoneNumber = PhoneNumber,
|
||||
Email = Email,
|
||||
};
|
||||
}
|
||||
}
|
@ -11,15 +11,14 @@ namespace UniversityDatabaseImplement
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR
|
||||
optionsBuilder.UseSqlServer(@"Data Source=(localdb)\UniversityDatabase;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-DYCTATOR\UniversityDatabase;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Student> Students { set; get; }
|
||||
public virtual DbSet<PlanOfStudy> PlanOfStudys { set; get; }
|
||||
public virtual DbSet<Attestation> Attestations { set; get; }
|
||||
public virtual DbSet<Worker> Workers { set; get; }
|
||||
public virtual DbSet<Storekeeper> Storekeepers { set; get; }
|
||||
public virtual DbSet<User> Users { set; get; }
|
||||
public virtual DbSet<Teacher> Teachers { set; get; }
|
||||
public virtual DbSet<Discipline> Disciplines { set; get; }
|
||||
public virtual DbSet<Statement> Statements { set; get; }
|
||||
|
Loading…
Reference in New Issue
Block a user