예제 #1
0
        private void InvokeCommandHandler(IMessage message)
        {
            HandlerDispatcher handlerDispatcher;
            if (!_messageTypeToCommandHandler.TryGetValue(message.GetType(), out handlerDispatcher))
            {
                var handlers = _assemblyScanner.FindCommandHandlersInAssemblies(message) ?? Enumerable.Empty<HandlerInfo>();

                if (!handlers.Any())
                    return;
                if (handlers.Count() > 1)
                    throw new Exception(string.Format("Multiple handlers present for command type {0} in app domain",
                                                      message.GetType().FullName));
                var methodInfo = handlers.Single();
                var handlertype = typeof(ICommandHandler<>);
                handlerDispatcher = new HandlerDispatcher(message.GetType(), GenerateHandleAction(handlertype.MakeGenericType(message.GetType())), methodInfo.HandleMethod.DeclaringType,
                                                                                                  methodInfo.IsStatic ? _objectFactory.GetInstance(methodInfo.HandleMethod.DeclaringType) : null);
                _messageTypeToCommandHandler[message.GetType()] = handlerDispatcher;
            }
            var instance = handlerDispatcher.Instance ?? _objectFactory.GetInstance(handlerDispatcher.HandlerType);
            handlerDispatcher.HandleMethod(instance, message);
        }
예제 #2
0
        private async Task FillViewDataDetailFormAsync(Institution item = null)
        {
            var cities = await HandlerDispatcher.ExecuteQueryAsync(new GetCitiesForInstitutionQuery());

            ViewData["CityId"] = new SelectList(cities, "Id", "Name", item?.CityId);
        }
예제 #3
0
        private async Task FillViewDataDetailFormAsync(City item = null)
        {
            var regions = await HandlerDispatcher.ExecuteQueryAsync(new GetRegionsForCityQuery());

            ViewData["RegionId"] = new SelectList(regions, "Id", "Name", item?.RegionId);
        }
        // GET: Admins
        public async Task <IActionResult> Admins()
        {
            var admins = await HandlerDispatcher.ExecuteQueryAsync(new GetAdminsQuery());

            return(View(admins));
        }
예제 #5
0
 public Task PartialUpdateCategory(PartialUpdateCategoryCommand command, CancellationToken token)
 => HandlerDispatcher.Invoke <PartialUpdateCategoryHandler, PartialUpdateCategoryCommand>(command, token);
예제 #6
0
 public Task UpdateCategory(UpdateCategoryCommand command, CancellationToken token)
 => HandlerDispatcher.Invoke <UpdateCategoryHandler, UpdateCategoryCommand>(command, token);
예제 #7
0
 public Task DeleteCategory(DeleteCategoryCommand command, CancellationToken token)
 => HandlerDispatcher.Invoke <DeleteCategoryHandler, DeleteCategoryCommand>(command, token);
예제 #8
0
 public Task AddCategoryBatch(AddCategoryBatchCommand command, CancellationToken token)
 => HandlerDispatcher.Invoke <AddCategoryBatchHandler, AddCategoryBatchCommand>(command, token);
예제 #9
0
 public Task ArchiveCategory(ArchiveCategoryCommand command, CancellationToken token)
 => HandlerDispatcher.Invoke <ArchiveCategoryHandler, ArchiveCategoryCommand>(command, token);
예제 #10
0
 public Task <CategoryDto> AddCategory(AddCategoryCommand command, CancellationToken token)
 => HandlerDispatcher.Invoke <AddCategoryHandler, AddCategoryCommand, CategoryDto>(command, token);
        private async Task FillViewDataDetailFormAsync(ContestDetailsViewModel viewModel = null)
        {
            var areas = await HandlerDispatcher.ExecuteQueryAsync(new GetAreasForContestQuery());

            ViewData["Areas"] = new MultiSelectList(areas, "Id", "Name", viewModel?.ContestAreas.Select(c => c.AreaId));
        }