2021-03-26 20:09:52 +04:00
|
|
|
|
using DatabaseCore;
|
|
|
|
|
using DatabaseCore.Models.Security;
|
2021-04-05 10:08:49 +04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2022-03-18 22:38:52 +04:00
|
|
|
|
using ToolsModule.Extensions;
|
|
|
|
|
using ToolsModule.Models;
|
2021-03-26 20:09:52 +04:00
|
|
|
|
using SecurityBusinessLogic.BindingModels;
|
|
|
|
|
using SecurityBusinessLogic.Interfaces;
|
|
|
|
|
using SecurityBusinessLogic.ViewModels;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2021-04-01 21:30:29 +04:00
|
|
|
|
namespace SecurityDatabaseImplementation.Implementations
|
2021-03-26 20:09:52 +04:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Реализация IEnviromentSettingService
|
|
|
|
|
/// </summary>
|
2021-04-05 10:08:49 +04:00
|
|
|
|
public class EnviromentSettingService :
|
|
|
|
|
AbstractGenerticEntityService<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel, EnviromentSetting, EnviromentSettingListViewModel, EnviromentSettingViewModel>,
|
|
|
|
|
IEnviromentSettingService
|
2021-03-26 20:09:52 +04:00
|
|
|
|
{
|
2021-04-05 10:08:49 +04:00
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, EnviromentSettingSetBindingModel model) => OperationResultModel.Success(null);
|
2021-03-26 20:09:52 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, EnviromentSetting entity, EnviromentSettingGetBindingModel model) => OperationResultModel.Success(null);
|
2021-03-26 20:09:52 +04:00
|
|
|
|
|
2021-04-27 15:14:35 +04:00
|
|
|
|
protected override IQueryable<EnviromentSetting> AdditionalCheckingWhenReadingList(IQueryable<EnviromentSetting> query, EnviromentSettingGetBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if(model.Key.IsNotEmpty())
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.Key == model.Key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return query;
|
|
|
|
|
}
|
2021-03-26 20:09:52 +04:00
|
|
|
|
|
2021-04-05 10:08:49 +04:00
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, EnviromentSettingSetBindingModel model) => OperationResultModel.Success(null);
|
2021-03-26 20:09:52 +04:00
|
|
|
|
|
2021-04-05 12:25:10 +04:00
|
|
|
|
protected override void AdditionalDeleting(DbContext context, EnviromentSetting entity, EnviromentSettingGetBindingModel model) { }
|
2021-03-26 20:09:52 +04:00
|
|
|
|
|
2021-04-05 10:08:49 +04:00
|
|
|
|
protected override EnviromentSetting GetUniqueEntity(EnviromentSettingSetBindingModel model, DbContext context) => context.Set<EnviromentSetting>().FirstOrDefault(x => x.Key == model.Key && x.Id != model.Id);
|
2021-03-26 20:09:52 +04:00
|
|
|
|
|
2021-04-05 10:08:49 +04:00
|
|
|
|
protected override IQueryable<EnviromentSetting> IncludingWhenReading(IQueryable<EnviromentSetting> query) => query;
|
2021-03-26 20:09:52 +04:00
|
|
|
|
|
2021-04-05 10:08:49 +04:00
|
|
|
|
protected override IQueryable<EnviromentSetting> OrderingWhenReading(IQueryable<EnviromentSetting> query) => query.OrderBy(x => x.Key);
|
2021-03-26 20:09:52 +04:00
|
|
|
|
}
|
|
|
|
|
}
|