Пример #1
0
        public async Task <IEnumerable <ContragentQuery> > Handle(GetContragentsByIdsQuery request, CancellationToken cancellationToken)
        {
            #region Persistence

            var contragentsDomain = await _ContragentRepository.GetByIds(request.Ids);

            var response = contragentsDomain.Select(item => item.ToQueryModel <ContragentQuery>(_Mapper));

            #endregion

            return(response);
        }
Пример #2
0
        public async Task <IEnumerable <Infrastructure.Database.Query.Model.Contragent> > GetContragentsOfProject(
            string ids,
            [Service] IServiceProvider serviceProvider,
            CancellationToken cancellationToken)
        {
            var guids = JsonConvert.DeserializeObject <List <Guid> >(ids);
            var getContragentsByIdsQuery = new GetContragentsByIdsQuery
            {
                Ids = guids
            };

            using (var scope = serviceProvider.CreateScope())
            {
                var mediator = scope.ServiceProvider.GetRequiredService <IMediator>();
                return(await mediator.Send(getContragentsByIdsQuery, cancellationToken));
            }
        }