public async Task <IActionResult> SendAddScreeningCommand( [FromBody] AddNewScreening source, [FromServices] IMessageBus messageBus) { AddScreening command = Translate(source); await messageBus.Send(new Envelope(command)); string uri = $"api/queries/Movies/{command.MovieId}/Screenings/{command.ScreeningId}"; return(Accepted(uri)); }
public async Task AddScreening_command_handler_adds_Screening_correctly( Guid theaterId, string name, [Range(1, 20)] int seatRowCount, [Range(1, 20)] int seatColumnCount, Movie movie, IFixture builder) { // Arange IEventSourcedRepository <Theater> theaterRepository = GetRepository(Theater.Factory); var theater = new Theater( theaterId, name, seatRowCount, seatColumnCount); await theaterRepository.SaveAndPublish(theater); IEventSourcedRepository <Movie> movieRepository = GetRepository(Movie.Factory); await movieRepository.SaveAndPublish(movie); var sut = new MovieCommandHandler( movieRepository, theaterRepository); AddScreening command = builder.Build <AddScreening>() .With(e => e.MovieId, movie.Id) .With(e => e.TheaterId, theaterId) .Create(); // Act await sut.Handle(new Envelope(command)); // Assert Movie actual = await movieRepository.Find(movie.Id); actual.Screenings .Should().Contain(s => s.Id == command.ScreeningId).Which .Should().BeEquivalentTo(new { Id = command.ScreeningId, command.TheaterId, Seats = from r in Enumerable.Range(0, seatRowCount) from c in Enumerable.Range(0, seatColumnCount) let isReserved = false select new Seat(row: r, column: c, isReserved), command.ScreeningTime, command.DefaultFee, command.ChildrenFee, }); }
private void ViewModel_AddingScreening(object sender, EventArgs e) { _mainView.Close(); _mainViewModel.LogoutSucceeded -= ViewModel_LogoutSucceeded; _mainViewModel.MessageApplication -= ViewModel_MessageApplication; _mainViewModel.BuyingTicket -= ViewModel_BuyingTicket; _mainViewModel.AddingMovie -= ViewModel_AddingMovie; _mainViewModel.AddingScreening -= ViewModel_AddingScreening; _addScreeningViewModel = new AddScreeningViewModel(_service); _addScreeningView = new AddScreening { DataContext = _addScreeningViewModel }; _addScreeningViewModel.AddingScreeningEnded += ViewModel_AddingScreeningEnded; _addScreeningView.Closed += ViewModel_AddingScreeningEnded; _addScreeningView.ShowDialog(); }
private async Task HandleAddScreening( Envelope <AddScreening> envelope, CancellationToken cancellationToken) { AddScreening command = envelope.Message; Movie movie = await _movieRepository.Find(command.MovieId); Theater theater = await _theaterRepository.Find(command.TheaterId); movie.AddScreening( command.ScreeningId, command.TheaterId, theater.SeatRowCount, theater.SeatColumnCount, command.ScreeningTime, command.DefaultFee, command.ChildrenFee); await _movieRepository.SaveAndPublish( movie, correlation : envelope, cancellationToken); }