public async Task <IEnumerable <DepartmentQuery> > Handle(GetDepartmentsByIdsQuery request, CancellationToken cancellationToken) { #region Persistence var departmentsDomain = await _DepartmentRepository.GetByIds(request.Ids); var response = departmentsDomain.Select(item => item.ToQueryModel <DepartmentQuery>(_Mapper)); #endregion return(response); }
public async Task <IEnumerable <Infrastructure.Database.Query.Model.Department> > GetDepartmentsOfProject( string ids, [Service] IServiceProvider serviceProvider, CancellationToken cancellationToken) { var guids = JsonConvert.DeserializeObject <List <Guid> >(ids); var getDepartmentByIdQuery = new GetDepartmentsByIdsQuery { Ids = guids //ids.Select(Guid.Parse).ToList() }; using (var scope = serviceProvider.CreateScope()) { var mediator = scope.ServiceProvider.GetRequiredService <IMediator>(); return(await mediator.Send(getDepartmentByIdQuery, cancellationToken)); } }