コード例 #1
0
        public async Task <int> CreateAsync(SessionCreateCommand command)
        {
            var room = await _roomRepository.SingleOrDefaultAsync(p => p.ID == command.RoomId);

            Guard.Against(room, ErrorType.NotFound);

            var movie = await _movieRepository.SingleOrDefaultAsync(p => p.ID == command.MovieId);

            Guard.Against(movie, ErrorType.NotFound);

            var session = _mapper.Map <Session>(command);

            session.MovieId = movie.ID;
            session.RoomId  = room.ID;

            var createdSession = await _repository.CreateAsync(session);

            return(await CommitAsync() > 0 ? createdSession.ID : 0);
        }
コード例 #2
0
 public async Task <IActionResult> CreateAsync(SessionCreateCommand command)
 {
     return(Ok(await _sessionService.CreateAsync(command)));
 }