Beispiel #1
0
        public async Task AddBots(InnerGameModel gameData, int id)
        {
            var DtoToEntities = new DTOToEntities();

            for (int i = 0; i < gameData.NameOfBots.Count; i++)
            {
                UserDTO bot = new UserDTO()
                {
                    TypeId = 2,
                    GameId = id
                };
                var modelViewToDto = new ModelViewToDTO();
                bot = modelViewToDto.GetBotDto(gameData.NameOfBots[i], bot);
                var   botEntity = DtoToEntities.GetBot(bot);
                var   task      = _userRepository.CreateAsync(botEntity);
                await task;
            }
        }
Beispiel #2
0
 public async Task AddBots(InnerGameViewModel gameData, int id)
 {
     try
     {
         for (int i = 0; i < gameData.nameOfBots.Count; i++)
         {
             var bot = new UserDTO();
             bot.TypeId = (int)PlayerTypeEnum.Bot;
             bot.GameId = id;
             bot        = _modelViewToDto.GetBotDto(gameData.nameOfBots[i], bot);
             var   botEntity = _dtoToEntities.GetBot(bot);
             var   task      = _userRepository.CreateAsync(botEntity);
             await task;
         }
     }
     catch (Exception e)
     {
         LogWriter.WriteLog(e.Message, "CreateGameService");
     }
 }