public async Task <bool> CheckIfEntityPlaceExistsByIdentificator(string PlaceIdOrTap, Guid?existingPlace) { if (string.IsNullOrEmpty(PlaceIdOrTap?.Trim())) { throw new ArgumentNullException(); } var date = _datetimeProvider.GetLocalNow().Date; var posSpec = new HasActiveEntityEntitySalesEntityPlaceSpecification(date) .And(new GetByIdEntityPlaceSpecification(PlaceIdOrTap)); if (existingPlace.HasValue) { posSpec = posSpec.And(new Entity.NotOwnedByEntitypecification(existingPlace.Value)); } var EntityPlace = (await _queryHandler.HandleAsync(posSpec.ToExpression(), asp => asp.PlaceId)); var SrnSpec = new SrnTermianlExactTapMatchingSpecification(PlaceIdOrTap) .And(new ActiveSrnPoolSpecification()); if (existingPlace.HasValue) { SrnSpec = SrnSpec.And(new Srn.NotOwnedByEntitypecification(existingPlace.Value)); } var SrnPools = await _queryHandler.HandleAsync(SrnSpec.ToExpression(), o => o.Offc); return(SrnPools.Any() || EntityPlace.Any()); }
public async Task <IGetEntityPlaceIdsAndRnTapsByTermQueryResult> Handle(GetEntityPlaceIdsAndRnTapsByTermQuery query) { var EusPlaceSpecification = Specification <EusPlace> .Empty; Specification <Lt> EntityPlaceSpecification = new NotEmptyPlaceIdLtSpecification(); Specification <Lt> grpPlaceSpecification = new NotEmptyGrpLtSpecification(); Specification <RnOffc> RnPlaceSpecification = new NotEmptyRnOffcSpecification(); if (!string.IsNullOrEmpty(query.Term)) { EusPlaceSpecification = EusPlaceSpecification.And(new FindByPlaceIdOffcSpecification(query.Term)); EntityPlaceSpecification = EntityPlaceSpecification.And(new FindByPlaceIdLtSpecification(query.Term)); RnPlaceSpecification = RnPlaceSpecification.And(new FindByRnOffcIdSpecification(query.Term)); } if (query.IdentityFilter?.AgentCodes?.Any() ?? false) { EusPlaceSpecification = EusPlaceSpecification.And(new ForAgentOffcSpecification(query.IdentityFilter.AgentCodes)); EntityPlaceSpecification = EntityPlaceSpecification.And(new ForAgentLtSpecification(query.IdentityFilter.AgentCodes)); RnPlaceSpecification = RnPlaceSpecification.And(new ForAgentRnOffcSpecification(query.IdentityFilter.AgentCodes)); } if (query.IdentityFilter?.RegionCodes?.Any() ?? false) { EusPlaceSpecification = EusPlaceSpecification.And(new ForRegionManagerOffcSpecification(query.IdentityFilter.RegionCodes)); EntityPlaceSpecification = EntityPlaceSpecification.And(new ForRegionLtSpecificaton(query.IdentityFilter.RegionCodes)); RnPlaceSpecification = RnPlaceSpecification.And(new ForRegionRnOffcSpecification(query.IdentityFilter.RegionCodes)); } var EusPlaceIds = await _queryHandler.HandleAsync(EusPlaceSpecification.ToExpression(), x => x.PlaceId, query); var EntityPlaceIds = await _queryHandler.HandleAsync(EntityPlaceSpecification.ToExpression(), x => x.PlaceId, query); var PlaceGrps = await _queryHandler.HandleAsync(EntityPlaceSpecification.ToExpression(), x => x.GRP, query); var RnOffcs = await _queryHandler.HandleAsync(RnPlaceSpecification.ToExpression(), x => x.Offc, query); var result = EusPlaceIds .Union(EntityPlaceIds) .Union(PlaceGrps) .Union(RnOffcs) .Distinct() .ApplyPaging(query) .ToArray(); if (!result.Any()) { return(GetEntityPlaceIdsAndRnTapsByTermQueryResult.Empty); } return(new GetEntityPlaceIdsAndRnTapsByTermQueryResult(result)); }
public async Task <IGetPlaceIdsByTermQueryResult> Handle(GetPlaceIdsByTermQuery query) { var UesPlaceSpecification = Specification <UesPlace> .Empty; var EntityPlaceSpecification = Specification <Ep> .Empty; if (!string.IsNullOrEmpty(query.Term)) { UesPlaceSpecification = UesPlaceSpecification.And(new FindByPlaceIdOffcSpecification(query.Term)); EntityPlaceSpecification = EntityPlaceSpecification.And(new FindByPlaceIdEpSpecification(query.Term)); } if (query.IdentityFilter?.AgentCodes?.Any() ?? false) { UesPlaceSpecification = UesPlaceSpecification.And(new ForAgentOffcSpecification(query.IdentityFilter.AgentCodes)); EntityPlaceSpecification = EntityPlaceSpecification.And(new ForAgentEpSpecification(query.IdentityFilter.AgentCodes)); } if (query.IdentityFilter?.RegionCodes?.Any() ?? false) { UesPlaceSpecification = UesPlaceSpecification.And(new ForRegionManagerOffcSpecification(query.IdentityFilter.RegionCodes)); EntityPlaceSpecification = EntityPlaceSpecification.And(new ForRegionEpSpecificaton(query.IdentityFilter.RegionCodes)); } var UesPlaceIds = await _queryHandler.HandleAsync(UesPlaceSpecification.ToExpression(), x => x.PlaceId, query); var EntityPlaceIds = await _queryHandler.HandleAsync(EntityPlaceSpecification.ToExpression(), x => x.PlaceId, query); var result = UesPlaceIds .Union(EntityPlaceIds) .Where(v => !string.IsNullOrEmpty(v)) .Distinct() .ApplyPaging(query) .ToArray(); if (!result.Any()) { return(GetPlaceIdsByTermQueryResult.Empty); } return(new GetPlaceIdsByTermQueryResult(result)); }
public async Task <EntityEntityAuthorizationStatus> Handle(Guid validityId) { if (validityId == Guid.Empty) { throw new ArgumentNullException(); } var specification = new AuthorizedEntitypecifcation(validityId); var queryResult = await _queryHandler.HandleAsync(specification.ToExpression(), v => v); var isAuthorized = queryResult.Any(); return(isAuthorized ? EntityEntityAuthorizationStatus.Authorized : EntityEntityAuthorizationStatus.NotAuthorized); }
public async Task <IGetAvailableEntityQueryResult> Handle(GetAvailableEntityQuery query) { var spec = new AvailableEntitySpecification(_datetimeProvider.GetLocalNow()); var availableEntity = await _queryHandler.HandleAsync(spec.ToExpression(), v => new EntityModel { EntityId = v.EntityGuid, Number = v.Number }, query); availableEntity = availableEntity .Where(n => EntityNumber.TryParse(n.Number, out var Entity) && Entity.IsControlNumberValid()) .ToArray(); return(new GetAvailableEntityQueryResult(availableEntity)); }
public async Task <SysTypesDto> Handle(Guid validityId) { if (validityId == Guid.Empty) { throw new ArgumentNullException(); } var queryResult = await _queryHandler.HandleAsync <EntityExpiration, SysType>(v => v.EntityExpirationGuid == validityId, v => v.EntityMainPoint.Sys); if (!queryResult.Any()) { throw new NotFoundException($"Валидатор с validityId {validityId} не найден для определения типа гдс"); } var Sys = queryResult.First(); return(Sys.ToSysDto()); }
public async Task <IGetEntityPlaceByPlaceIdQueryResult> Handle(GetEntityPlaceByPlaceIdQuery query) { if (string.IsNullOrWhiteSpace(query.PlaceId)) { return(GetEntityPlaceByPlaceIdQueryResult.Empty); } if (query.PlaceId.IsDirectPlace()) { return(GetEntityPlaceByPlaceIdQueryResult.ForbiddenResult); } var date = _datetimeProvider.GetLocalNow().Date; var posSpec = new HasActiveEntityEntitySalesEntityPlaceSpecification(date) .And(new GetByIdEntityPlaceSpecification(query.PlaceId)); var EntityPlace = (await _queryHandler.HandleAsync(posSpec.ToExpression(), asp => asp)).FirstOrDefault(); return(EntityPlace == null ? GetEntityPlaceByPlaceIdQueryResult.Empty : new GetEntityPlaceByPlaceIdQueryResult(EntityPlace.EpGuid, EntityPlace.EntityBasePoint.AgentCode)); }
public async Task <IGetEntityByTermQueryResult> Handle(GetEntityByTermQuery query) { Specification <EntityExpiration> EntityEntityOwnerSpecification = new ActiveEntityNumberSpecification(); var EusEntityOwnerSpecification = Specification <EusPlace> .Empty; if (!string.IsNullOrEmpty(query.Term)) { EusEntityOwnerSpecification = EusEntityOwnerSpecification.And(new FindByEusEntityNumberSpecification(query.Term)); EntityEntityOwnerSpecification = EntityEntityOwnerSpecification.And(new FindByEntityEntityNumberSpecification(query.Term)); } if (query.IdentityFilter?.AgentCodes?.Any() ?? false) { EntityEntityOwnerSpecification = EntityEntityOwnerSpecification.And(new ForAgentEntityEntitypecification(query.IdentityFilter.AgentCodes)); EusEntityOwnerSpecification = EusEntityOwnerSpecification.And(new ForAgentEusEntitypecification(query.IdentityFilter.AgentCodes)); } if (query.IdentityFilter?.RegionCodes?.Any() ?? false) { EntityEntityOwnerSpecification = EntityEntityOwnerSpecification.And(new ForRegionEntityEntitypecification(query.IdentityFilter.RegionCodes)); EusEntityOwnerSpecification = EusEntityOwnerSpecification.And(new ForRegionEusEntitypecification(query.IdentityFilter.RegionCodes)); } var result = await _queryHandler.HandleAsync(EusEntityOwnerSpecification.ToExpression(), x => x.DefaultNumberValidity.Select(y => new EntityhortResultProjection { Id = y.DefaultNumber.Id, Number = y.DefaultNumber.Number, }), query); if (!query.OnlyWithAuthorizedAccess) { var EntityEntityResult = await _queryHandler.HandleAsync(EntityEntityOwnerSpecification.ToExpression(), x => new EntityhortResultProjection { Id = x.Entity.EntityGuid, Number = x.Entity.Number }, query); var EusAuthorizedAccessEntityResult = await _queryHandler.HandleAsync(EusEntityOwnerSpecification.ToExpression(), x => x.UADefaultNumberValidity.Select(y => new EntityhortResultProjection { Id = y.UADefaultNumber.Id, Number = y.UADefaultNumber.Number }), query); result = result.Union(EntityEntityResult) .Union(EusAuthorizedAccessEntityResult).ToArray(); } var response = result .Distinct() .ApplyPaging(query); if (!response.Any()) { return(GetEntityByTermQueryResult.Empty); } return(new GetEntityByTermQueryResult(response.Select(v => new EntityItem { Id = v.Id, Name = v.Number, }).ToArray())); }