2021-04-06 22:07:11 +04:00
|
|
|
|
using DatabaseCore;
|
|
|
|
|
using DatabaseCore.Models.Department;
|
|
|
|
|
using DepartmentBusinessLogic.BindingModels;
|
|
|
|
|
using DepartmentBusinessLogic.Interfaces;
|
|
|
|
|
using DepartmentBusinessLogic.ViewModels;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2022-03-18 22:38:52 +04:00
|
|
|
|
using ToolsModule.Models;
|
2021-04-06 22:07:11 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace DepartmentDatabaseImplementation.Implementations
|
|
|
|
|
{
|
|
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
}
|