45 lines
2.0 KiB
C#
45 lines
2.0 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.Models;
|
|
|
|
namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntityService
|
|
{
|
|
/// <summary>
|
|
/// Реализация ITimeNormService
|
|
/// </summary>
|
|
public class TimeNormService :
|
|
AbstractGenerticEntityService<TimeNormGetBindingModel, TimeNormSetBindingModel, TimeNorm, TimeNormListViewModel, TimeNormViewModel>,
|
|
ITimeNormService
|
|
{
|
|
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, TimeNormSetBindingModel model) => OperationResultModel.Success(null);
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, TimeNorm entity, TimeNormGetBindingModel model)
|
|
{
|
|
return OperationResultModel.Success(null);
|
|
}
|
|
|
|
protected override IQueryable<TimeNorm> AdditionalCheckingWhenReadingList(IQueryable<TimeNorm> query, TimeNormGetBindingModel model)
|
|
{
|
|
if (model.DisciplineBlockId.HasValue)
|
|
{
|
|
query = query.Where(x => x.DisciplineBlockId == model.DisciplineBlockId.Value);
|
|
}
|
|
return query;
|
|
}
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, TimeNormSetBindingModel model) => OperationResultModel.Success(null);
|
|
|
|
protected override void AdditionalDeleting(DbContext context, TimeNorm entity, TimeNormGetBindingModel model) { }
|
|
|
|
protected override TimeNorm GetUniqueEntity(TimeNormSetBindingModel model, DbContext context) => context.Set<TimeNorm>().FirstOrDefault(x => x.TimeNormName == model.TimeNormName && x.TimeNormShortName == model.TimeNormShortName && x.Id != model.Id);
|
|
|
|
protected override IQueryable<TimeNorm> IncludingWhenReading(IQueryable<TimeNorm> query) => query.Include(x => x.DisciplineBlock);
|
|
|
|
protected override IQueryable<TimeNorm> OrderingWhenReading(IQueryable<TimeNorm> query) => query.OrderBy(x => x.TimeNormOrder);
|
|
}
|
|
} |