43 lines
2.4 KiB
C#
43 lines
2.4 KiB
C#
using DatabaseCore;
|
|
using DatabaseCore.Models.Department;
|
|
using DepartmentBusinessLogic.BindingModels;
|
|
using DepartmentBusinessLogic.Interfaces;
|
|
using DepartmentBusinessLogic.ViewModels;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using ModuleTools.Enums;
|
|
using ModuleTools.Models;
|
|
using System.Linq;
|
|
|
|
namespace DepartmentDatabaseImplementation.Implementations
|
|
{
|
|
/// <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, DbContext context) => context.Set<LecturerAcademicDegree>().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);
|
|
}
|
|
} |