2021-04-03 23:46:48 +04:00
|
|
|
|
using DatabaseCore;
|
|
|
|
|
using DatabaseCore.Models.Department;
|
|
|
|
|
using DepartmentBusinessLogic.BindingModels;
|
|
|
|
|
using DepartmentBusinessLogic.Interfaces;
|
|
|
|
|
using DepartmentBusinessLogic.ViewModels;
|
2021-04-05 12:25:10 +04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2022-03-18 22:38:52 +04:00
|
|
|
|
using ToolsModule.Enums;
|
|
|
|
|
using ToolsModule.Models;
|
2021-04-03 23:46:48 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace DepartmentDatabaseImplementation.Implementations
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Реализация ILecturerAcademicDegreeService
|
|
|
|
|
/// </summary>
|
2021-04-05 12:25:10 +04:00
|
|
|
|
public class LecturerAcademicDegreeService :
|
|
|
|
|
AbstractGenerticEntityService<LecturerAcademicDegreeGetBindingModel, LecturerAcademicDegreeSetBindingModel, LecturerAcademicDegree, LecturerAcademicDegreeListViewModel, LecturerAcademicDegreeViewModel>,
|
|
|
|
|
ILecturerAcademicDegreeService
|
2021-04-03 23:46:48 +04:00
|
|
|
|
{
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, LecturerAcademicDegreeSetBindingModel model) => OperationResultModel.Success(null);
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, LecturerAcademicDegree entity, LecturerAcademicDegreeGetBindingModel model)
|
2021-04-03 23:46:48 +04:00
|
|
|
|
{
|
2021-04-05 12:25:10 +04:00
|
|
|
|
if (context.Set<Lecturer>().Any(x => x.LecturerAcademicDegreeId == model.Id && !x.IsDeleted))
|
2021-04-03 23:46:48 +04:00
|
|
|
|
{
|
|
|
|
|
return OperationResultModel.Error("Error:", "Имеются сотрудники, использующую эту запись", ResultServiceStatusCode.ExsistItem);
|
|
|
|
|
}
|
2021-04-05 12:25:10 +04:00
|
|
|
|
return OperationResultModel.Success(null);
|
2021-04-03 23:46:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override IQueryable<LecturerAcademicDegree> AdditionalCheckingWhenReadingList(IQueryable<LecturerAcademicDegree> query, LecturerAcademicDegreeGetBindingModel model) => query;
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, LecturerAcademicDegreeSetBindingModel model) => OperationResultModel.Success(null);
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override void AdditionalDeleting(DbContext context, LecturerAcademicDegree entity, LecturerAcademicDegreeGetBindingModel model) { }
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override LecturerAcademicDegree GetUniqueEntity(LecturerAcademicDegreeSetBindingModel model, DbContext context) => context.Set<LecturerAcademicDegree>().FirstOrDefault(x => x.LecturerAcademicDegreeName == model.LecturerAcademicDegreeName && x.Id != model.Id);
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override IQueryable<LecturerAcademicDegree> IncludingWhenReading(IQueryable<LecturerAcademicDegree> query) => query;
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override IQueryable<LecturerAcademicDegree> OrderingWhenReading(IQueryable<LecturerAcademicDegree> query) => query.OrderBy(x => x.Order);
|
2021-04-03 23:46:48 +04:00
|
|
|
|
}
|
|
|
|
|
}
|