public async Task <Dto.Game?> UpdateAsync(int id, Dto.GameInput input) { Game entity = _mapper.Map <Dto.GameInput, Game>(input); Game?result = await _gameRepository.UpdateAsync(id, entity); return(result is null ? null :_mapper.Map <Game, Dto.Game>(result)); }
public async Task <Dto.Game?> CreateAsync(Dto.GameInput dto) { Game entity = _mapper.Map <Dto.GameInput, Game>(dto); int userId = _sessionService.GetCurrentUserId(); User user = await _userService.GetUserById(userId) ?? throw new IllegalStateException(nameof(User)); entity.GameMaster = user.Id; entity.GameUsers.Add(new GameUser(user.Id, user, entity.Id, entity)); await _calendarService.InsertAsync(dto.GameTime !); await _gameRepository.InsertAsync(entity); _sessionService.SetCurrentGameId(entity.Id); return(_mapper.Map <Game, Dto.Game>(entity)); }