예제 #1
0
        public async Task <ActionResult> AddUserAsync([FromBody] CreateUserCommand command)
        {
            if (ModelState.IsValid)
            {
                User user = await userManager.FindByEmailAsync(command.Email);

                if (user == null)
                {
                    await pipelineService.HandleCommandAsync(command);

                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #2
0
        public async Task <IActionResult> Upload(string movieIdsString)
        {
            string[] movieIds = movieIdsString.Trim(' ').Split(',', ';');

            var command = new ImportImdbMoviesInfoCommand
            {
                ImdbMovieIds = movieIds
            };

            await pipelineService.HandleCommandAsync(command);

            return(View());
        }
예제 #3
0
        public async Task <ActionResult> AddListingAsync([FromBody] CreateListingCommand command)
        {
            if (ModelState.IsValid)
            {
                await pipelineService.HandleCommandAsync(command);

                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #4
0
        public async Task Should_dispose_command_handlers_after_instaniate_if_use_internal_object_resolver_async()
        {
            // Arrange
            pipelineService.PipelineContainer.AddCommandPipeline()
            .AddMiddleware(new Commands.PipelineMiddlewares.CommandHandlerLocatorMiddleware(
                               typeof(CommandsTests).GetTypeInfo().Assembly))
            .AddMiddleware(new Commands.PipelineMiddlewares.CommandHandlerResolverMiddleware())
            .AddMiddleware(new Commands.PipelineMiddlewares.CommandHandlerExecutorMiddleware
            {
                UseParametersResolve = true
            });
            var cmd = new TestCommand();

            // Act
            await pipelineService.HandleCommandAsync(cmd);

            // Assert
            Assert.True(TestCommandHandler.IsDisposed);
        }
예제 #5
0
        public async Task <ActionResult> ResetPasswordAsync([FromBody] ResetUserPasswordCommand command)
        {
            if (ModelState.IsValid)
            {
                User user = await userManager.FindByEmailAsync(command.Email);

                if (user == null)
                {
                    return(BadRequest());
                }

                string resetToken = await userManager.GeneratePasswordResetTokenAsync(user);

                command.ResetToken = resetToken;

                await pipelineService.HandleCommandAsync(command);

                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #6
0
 public async Task AddCommentAsync([FromBody] CreateCommentCommand command)
 {
     command.CreatedByUserId = (await userManager.FindByEmailAsync(User.Identity.Name)).Id;
     await pipelineService.HandleCommandAsync(command);
 }