DepartmentProject/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/AbstractGenerticEntityService/LecturerAcademicDegreeService.cs

42 lines
2.4 KiB
C#

using CoreDatabase;
using CoreDatabase.Models.Department;
using DepartmentContract.BindingModels;
using DepartmentContract.Services.IGenericEntityService;
using DepartmentContract.ViewModels;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using ToolsModule.ManagmentEntity;
namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntityService
{
/// <summary>
/// Реализация ILecturerAcademicDegreeService
/// </summary>
public class LecturerAcademicDegreeService :
AbstractGenerticEntityService<LecturerAcademicDegreeGetBindingModel, LecturerAcademicDegreeSetBindingModel, LecturerAcademicDegree, LecturerAcademicDegreeListViewModel, LecturerAcademicDegreeViewModel>,
ILecturerAcademicDegreeService
{
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, LecturerAcademicDegreeSetBindingModel model) => OperationResultModel.Success(null);
protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, LecturerAcademicDegree entity, LecturerAcademicDegreeGetBindingModel model)
{
if (context.Set<Lecturer>().Any(x => x.LecturerAcademicDegreeId == model.Id && !x.IsDeleted))
{
return OperationResultModel.Error("Error:", "Имеются сотрудники, использующую эту запись", ResultServiceStatusCode.ExsistItem);
}
return OperationResultModel.Success(null);
}
protected override IQueryable<LecturerAcademicDegree> AdditionalCheckingWhenReadingList(IQueryable<LecturerAcademicDegree> query, LecturerAcademicDegreeGetBindingModel model) => query;
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, LecturerAcademicDegreeSetBindingModel model) => OperationResultModel.Success(null);
protected override void AdditionalDeleting(DbContext context, LecturerAcademicDegree entity, LecturerAcademicDegreeGetBindingModel model) { }
protected override LecturerAcademicDegree GetUniqueEntity(LecturerAcademicDegreeSetBindingModel model, IQueryable<LecturerAcademicDegree> query) => query.FirstOrDefault(x => x.LecturerAcademicDegreeName == model.LecturerAcademicDegreeName && x.Id != model.Id);
protected override IQueryable<LecturerAcademicDegree> IncludingWhenReading(IQueryable<LecturerAcademicDegree> query) => query;
protected override IQueryable<LecturerAcademicDegree> OrderingWhenReading(IQueryable<LecturerAcademicDegree> query) => query.OrderBy(x => x.Order);
}
}