46 lines
2.1 KiB
C#
46 lines
2.1 KiB
C#
using CoreDatabase;
|
|
using CoreDatabase.Models.Department;
|
|
using DepartmentBusinessLogic.BindingModels;
|
|
using DepartmentBusinessLogic.Interfaces;
|
|
using DepartmentBusinessLogic.ViewModels;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using ToolsModule.Models;
|
|
using System.Linq;
|
|
|
|
namespace DepartmentDatabaseImplementation.Implementations
|
|
{
|
|
/// <summary>
|
|
/// Реализация ILecturerPostService
|
|
/// </summary>
|
|
public class LecturerPostService :
|
|
AbstractGenerticEntityService<LecturerPostGetBindingModel, LecturerPostSetBindingModel, LecturerPost, LecturerPostListViewModel, LecturerPostViewModel>,
|
|
ILecturerPostService
|
|
{
|
|
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, LecturerPostSetBindingModel model) => OperationResultModel.Success(null);
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, LecturerPost entity, LecturerPostGetBindingModel model) => OperationResultModel.Success(null);
|
|
|
|
protected override IQueryable<LecturerPost> AdditionalCheckingWhenReadingList(IQueryable<LecturerPost> query, LecturerPostGetBindingModel model)
|
|
{
|
|
if (model.PostId.HasValue)
|
|
{
|
|
query = query.Where(x => x.PostId == model.PostId);
|
|
}
|
|
if (model.LecturerId.HasValue)
|
|
{
|
|
query = query.Where(x => x.LecturerId == model.LecturerId);
|
|
}
|
|
return query;
|
|
}
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, LecturerPostSetBindingModel model) => OperationResultModel.Success(null);
|
|
|
|
protected override void AdditionalDeleting(DbContext context, LecturerPost entity, LecturerPostGetBindingModel model) { }
|
|
|
|
protected override LecturerPost GetUniqueEntity(LecturerPostSetBindingModel model, DbContext context) => context.Set<LecturerPost>().FirstOrDefault(x => x.LecturerId == model.LecturerId && x.PostId == model.PostId && x.Id != model.Id);
|
|
|
|
protected override IQueryable<LecturerPost> IncludingWhenReading(IQueryable<LecturerPost> query) => query.Include(x => x.Post).Include(x => x.Lecturer);
|
|
|
|
protected override IQueryable<LecturerPost> OrderingWhenReading(IQueryable<LecturerPost> query) => query.OrderBy(x => x.Lecturer.LastName);
|
|
}
|
|
} |