Example #1
0
        public async Task <IActionResult> Get(Guid id)
        {
            var cmd    = new GetDepartmentByIdQuery(id);
            var result = await _mediator.Send(cmd);

            return(Ok(result));
        }
Example #2
0
        public async Task <DepartmentQuery> Handle(GetDepartmentByIdQuery request, CancellationToken cancellationToken)
        {
            #region Persistence

            var departmentDomain = await _DepartmentRepository.GetById(request.Id);

            var response = departmentDomain.ToQueryModel <DepartmentQuery>(_Mapper);

            #endregion

            return(response);
        }
Example #3
0
        public async Task <Infrastructure.Database.Query.Model.Department> GetDepartmentById(
            [GraphQLType(typeof(IdType))] Guid id,
            [Service] IServiceProvider serviceProvider,
            CancellationToken cancellationToken)
        {
            var getDepartmentByIdQuery = new GetDepartmentByIdQuery
            {
                Id = id
            };

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