Esempio n. 1
0
 public MoviesController()
 {
     _createMovieCommand = new CreateMovieCommand();
     _deleteMovieCommand = new DeleteMovieCommand();
     _getAllMoviesQuery  = new GetAllMoviesQuery();
     _searchMoviesQuery  = new SearchMoviesQuery();
     _editMovieCommand   = new EditMovieCommand();
 }
Esempio n. 2
0
        public void ShouldRequireValidTodoListId()
        {
            var command = new DeleteMovieCommand {
                Id = 99
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
        public async Task <IActionResult> DeleteMovie(DeleteMovieCommand model, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(model, cancellationToken);

            if (result)
            {
                return(Ok());
            }

            return(BadRequest());
        }
        public IActionResult DeleteMovie(int id)
        {
            var command = new DeleteMovieCommand(id);

            DomainDispatcher.ExecuteCommand(command);

            if (command.WasSuccesful)
            {
                return(NoContent());
            }
            else
            {
                return(BadRequest());
            }
        }
Esempio n. 5
0
        public MainViewModel(Library library, INavigator navigator, ILibraryStore store, IChangeTracker changeTracker)
            : base(library)
        {
            Ensure.NotNull(navigator, "navigator");
            Ensure.NotNull(changeTracker, "changeTracker");

            changeTracker.Added   += () => HasChange = true;
            changeTracker.Cleared += () => HasChange = false;

            Create            = new DelegateCommand(() => navigator.CreateMovieAsync(library));
            Edit              = new EditMovieCommand(library, navigator);
            Delete            = new DeleteMovieCommand(library.Movies, navigator, changeTracker);
            Save              = new SaveCommand(library, store);
            OpenConfiguration = new DelegateCommand(() => navigator.LibraryConfigurationAsync(library));
        }
Esempio n. 6
0
        public async Task Handle(DeleteMovieCommand command)
        {
            Movie entity = await _movieRepository.GetAsync(command.Id);

            if (entity == null || entity.IsDeleted)
            {
                _logger.LogWarning("Movie with id {id} is already deleted", command.Id);
            }
            else
            {
                entity.IsDeleted = true;

                await _movieRepository.UpdateAsync(entity);

                await _bus.Publish(command.CreateUpdatedEvent());

                _logger.LogInformation("Movie with id {id} has been deleted", command.Id);
            }
        }
Esempio n. 7
0
        public async Task <IActionResult> DeleteMovieByIdAsync(int id)
        {
            var model = await _mediator.Send(new GetMovieByIdQuery(id));

            if (model.Title.Contains("F#"))
            {
                return(BadRequest("F# best language"));
            }

            var command  = new DeleteMovieCommand(id);
            var response = await _mediator.Send(command);

            if (response == null)
            {
                return(NotFound(new MovieNotFoundResponse(command.MovieId)));
            }

            return(Ok(response));
        }
 public DeleteMovieResult DeleteDirector(DeleteMovieCommand director)
 {
     throw new NotImplementedException();
 }
        public async Task <IActionResult> DeleteMovie([FromBody] DeleteMovieCommand command)
        {
            var result = await Mediator.Send(command);

            return(Ok(result));
        }
Esempio n. 10
0
        public async Task <IActionResult> DeleteMovie(DeleteMovieCommand model, CancellationToken cancellationToken)
        {
            await _mediator.Send(model, cancellationToken);

            return(Ok());
        }