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 <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));
        }