public async Task <CreateSessionResponse> Handle(CreateSessionCommand message) { var cinema = await _cinemaRepository.GetCinemaById(message.CinemaId); if (cinema == null) { throw new InvalidOperationException($"The cinema with id [{message.CinemaId}] can not be found"); } var film = await _filmRepository.GetFilmById(message.FilmId); if (film == null) { throw new InvalidOperationException($"The film with id [{message.FilmId}] can not be found"); } var screen = cinema.Screens.SingleOrDefault(s => s.Id == message.ScreenId); if (screen == null) { throw new InvalidOperationException($"The screen with id [{message.ScreenId}] can not be found in the cinema [{message.CinemaId}]"); } var session = Session.Create( screen, film, message.Start); await _sessionRepository.AddAsync(session); await _unitOfWork.CommitAsync(); return(new CreateSessionResponse(SessionViewModel.FromSession(session))); }