public PlayerDTO CreatePlayer(AlexaAccountDTO alexaAccountDto) { using (var context = new RealmContext()) { var defaultPlayer = context.Players.AsNoTracking().Single(o => o.PlayerId == Guid.Empty); var player = new Player { PlayerId = Guid.NewGuid(), Name = defaultPlayer.Name, MapRefId = defaultPlayer.MapRefId, LocationX = defaultPlayer.LocationX, LocationY = defaultPlayer.LocationY, Level = defaultPlayer.Level, Verbosity = defaultPlayer.Verbosity, Gold = defaultPlayer.Gold, Energy = defaultPlayer.Energy, Toughness = defaultPlayer.Toughness, AccountRefId = alexaAccountDto.AccountId }; context.Entry(player).State = EntityState.Added; context.SaveChanges(); var playerDto = Mapper.Map <PlayerDTO>(player); playerDto.Inventories = new List <InventoryDTO>(); return(playerDto); } }
public PlayerDTO GetPlayer(AlexaAccountDTO alexaAccountDto) { PlayerDTO playerDto = null; if (alexaAccountDto.AccountId != Guid.Empty) { playerDto = this.alexaRepository.GetPlayerByAccountId(alexaAccountDto.AccountId); } return(playerDto ?? this.alexaRepository.CreatePlayer(alexaAccountDto)); }
public void LogRequest(AlexaRequestDTO alexaRequestDTO, AlexaAccountDTO alexaAccountDTO) { alexaRequestDTO.AccountRefId = alexaAccountDTO.AccountId; this.alexaRepository.LogRequest(alexaRequestDTO); }