DepartmentProject/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/AbstractGenerticEntityService/EnviromentSettingService.cs

44 lines
2.1 KiB
C#
Raw Permalink Normal View History

2022-03-18 22:55:48 +04:00
using CoreDatabase;
using CoreDatabase.Models.Security;
using Microsoft.EntityFrameworkCore;
using SecurityContract.BindingModels;
using SecurityContract.Services.IGenericEntityService;
using SecurityContract.ViewModels;
using System.Linq;
2022-03-20 10:10:44 +04:00
using ToolsModule.ManagmentEntity;
using ToolsModule.ManagmentExtension;
namespace SecurityDatabaseImplementation.Implementations.AbstractGenerticEntityService
{
/// <summary>
/// Реализация IEnviromentSettingService
/// </summary>
public class EnviromentSettingService :
AbstractGenerticEntityService<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel, EnviromentSetting, EnviromentSettingListViewModel, EnviromentSettingViewModel>,
IEnviromentSettingService
{
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, EnviromentSettingSetBindingModel model) => OperationResultModel.Success(null);
protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, EnviromentSetting entity, EnviromentSettingGetBindingModel model) => OperationResultModel.Success(null);
protected override IQueryable<EnviromentSetting> AdditionalCheckingWhenReadingList(IQueryable<EnviromentSetting> query, EnviromentSettingGetBindingModel model)
{
if(model.Key.IsNotEmpty())
{
query = query.Where(x => x.Key == model.Key);
}
return query;
}
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, EnviromentSettingSetBindingModel model) => OperationResultModel.Success(null);
protected override void AdditionalDeleting(DbContext context, EnviromentSetting entity, EnviromentSettingGetBindingModel model) { }
protected override EnviromentSetting GetUniqueEntity(EnviromentSettingSetBindingModel model, IQueryable<EnviromentSetting> query) => query.FirstOrDefault(x => x.Key == model.Key && x.Id != model.Id);
protected override IQueryable<EnviromentSetting> IncludingWhenReading(IQueryable<EnviromentSetting> query) => query;
protected override IQueryable<EnviromentSetting> OrderingWhenReading(IQueryable<EnviromentSetting> query) => query.OrderBy(x => x.Key);
}
}