Exemple #1
0
        // GET: SelectRequest
        public IActionResult Index()
        {
            var query   = new GetDepartmentsQuery();
            var handler = QueryHandlerFactory.Build(query);

            return(View(handler.Execute(_session)));
        }
Exemple #2
0
        public async Task <List <DepartmentProjection> > GetAllDepartments()
        {
            var query  = new GetDepartmentsQuery();
            var result = await _queryProcessor.Process(query);

            return(result);
        }
        public async Task <IEnumerable <DepartmentViewModel> > Handle(GetDepartmentsQuery request, CancellationToken cancellationToken)
        {
            var departments = await DepartmentRepository.Select();

            var viewmodel = new List <DepartmentViewModel>();

            foreach (var item in departments)
            {
                var vm = new DepartmentViewModel();
                vm.LoadFromDomain(item);
                vm.IsSelected = item.Id == request.SelectedId;
                viewmodel.Add(vm);
            }
            return(viewmodel.OrderBy(item => item.Level).ThenBy(item => item.Name).ToList());
        }
Exemple #4
0
        public async void given_get_department_query_query_processor_should_get_same_query_created_in_controller()
        {
            var mockAgg = new DepartmentControllerMockAggregate();

            var controller = mockAgg.DepartmentControllerFactory();

            var command = new GetDepartmentsQuery();

            mockAgg.setup_processor_to_verify_getDepartmentQuery_are_the_same();

            var result = await controller.GetAllDepartments();

            //Assert
            Assert.IsType <List <DepartmentProjection> > (result);
        }
        public async Task <List <GetDepartmentsQueryModel> > Handle(GetDepartmentsQuery message, CancellationToken cancellationToken)
        {
            var departments = await _readModelRepository.All <DepartmentReadModel>();

            var model = departments.Select(x =>

                                           new GetDepartmentsQueryModel()
            {
                Id            = x.Id,
                Administrator = x.Administrator,
                Budget        = x.Budget,
                Name          = x.Name,
                StartDate     = x.StartDate
            }
                                           );

            return(model.ToList());
        }
Exemple #6
0
 public Task <List <DepartmentProjection> > Handle(GetDepartmentsQuery query)
 {
     return(Task.FromResult(_context.DepartmentProjection.ToList()));
 }
Exemple #7
0
 public static IQueryHandler <GetDepartmentsQuery, List <DepartmentExpanded> > Build(GetDepartmentsQuery query)
 {
     return(new GetDepartmentsQueryHandler());
 }