2022-03-18 22:55:48 +04:00
|
|
|
|
using CoreDatabase;
|
|
|
|
|
using CoreDatabase.Models.Department;
|
2022-03-19 22:48:13 +04:00
|
|
|
|
using DepartmentContract.BindingModels;
|
|
|
|
|
using DepartmentContract.Services.IGenericEntityService;
|
|
|
|
|
using DepartmentContract.ViewModels;
|
2021-04-05 12:25:10 +04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2022-03-19 22:48:13 +04:00
|
|
|
|
using System.Linq;
|
2022-03-20 10:10:44 +04:00
|
|
|
|
using ToolsModule.ManagmentEntity;
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2022-03-19 22:48:13 +04:00
|
|
|
|
namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntityService
|
2021-04-03 23:46:48 +04:00
|
|
|
|
{
|
2022-03-19 22:48:13 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Реализация ILecturerAcademicRankService
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LecturerAcademicRankService :
|
2021-04-05 12:25:10 +04:00
|
|
|
|
AbstractGenerticEntityService<LecturerAcademicRankGetBindingModel, LecturerAcademicRankSetBindingModel, LecturerAcademicRank, LecturerAcademicRankListViewModel, LecturerAcademicRankViewModel>,
|
|
|
|
|
ILecturerAcademicRankService
|
2021-04-03 23:46:48 +04:00
|
|
|
|
{
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, LecturerAcademicRankSetBindingModel 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, LecturerAcademicRank entity, LecturerAcademicRankGetBindingModel model)
|
2021-04-03 23:46:48 +04:00
|
|
|
|
{
|
2021-04-05 12:25:10 +04:00
|
|
|
|
if (context.Set<Lecturer>().Any(x => x.LecturerAcademicRankId == 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<LecturerAcademicRank> AdditionalCheckingWhenReadingList(IQueryable<LecturerAcademicRank> query, LecturerAcademicRankGetBindingModel model) => query;
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, LecturerAcademicRankSetBindingModel 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, LecturerAcademicRank entity, LecturerAcademicRankGetBindingModel model) { }
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2022-03-29 13:33:32 +04:00
|
|
|
|
protected override LecturerAcademicRank GetUniqueEntity(LecturerAcademicRankSetBindingModel model, IQueryable<LecturerAcademicRank> query) => query.FirstOrDefault(x => x.LecturerAcademicRankName == model.LecturerAcademicRankName && x.Id != model.Id);
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override IQueryable<LecturerAcademicRank> IncludingWhenReading(IQueryable<LecturerAcademicRank> query) => query;
|
2021-04-03 23:46:48 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override IQueryable<LecturerAcademicRank> OrderingWhenReading(IQueryable<LecturerAcademicRank> query) => query.OrderBy(x => x.Order);
|
2021-04-03 23:46:48 +04:00
|
|
|
|
}
|
|
|
|
|
}
|