using CoreDatabase; using CoreDatabase.Models.Security; using Microsoft.EntityFrameworkCore; using SecurityContract.BindingModels; using SecurityContract.Services.IGenericEntityService; using SecurityContract.ViewModels; using System.Linq; using ToolsModule.Extensions; using ToolsModule.Models; namespace SecurityDatabaseImplementation.Implementations.AbstractGenerticEntityService { /// /// Реализация IEnviromentSettingService /// public class EnviromentSettingService : AbstractGenerticEntityService, 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 AdditionalCheckingWhenReadingList(IQueryable 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, DbContext context) => context.Set().FirstOrDefault(x => x.Key == model.Key && x.Id != model.Id); protected override IQueryable IncludingWhenReading(IQueryable query) => query; protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.Key); } }