Exemplo n.º 1
0
        public static void CreateGameInfo(GameInfoDTO gameInfoDTO)
        {
            // ballpark instance of Player class in Retrosheet_Persist.Retrosheet
            var gameInfo = convertToEntity(gameInfoDTO);

            // entity data model
            //var dbCtx = new retrosheetDB();
            var dbCtx = new retrosheetEntities();

            dbCtx.Game_Info.Add(gameInfo);
            try
            {
                dbCtx.SaveChanges();
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            catch (Exception e)
            {
                string text;
                text = e.Message;
            }
        }
Exemplo n.º 2
0
        private static void ReadWriteGameInfoFile(string inputPathFile)
        {
            string[] columnValue;
            string   textLine = null;

            using (StreamReader reader = new StreamReader(inputPathFile))
            {
                while (!reader.EndOfStream)
                {
                    try
                    {
                        textLine = reader.ReadLine();
                    }
                    catch (Exception e)
                    {
                        // Let the user know what went wrong.
                        Console.WriteLine("The " + @"C:\users\mmr\documents\retrosheet\2016 Regular Season\Output\2016SLN\2016SLN_gameinfo" + " file could not be read:");
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }

                    columnValue = textLine.Split('|');

                    GameInfoDTO gameInfoDTO = new GameInfoDTO();

                    gameInfoDTO.RecordID      = Guid.NewGuid();
                    gameInfoDTO.GameID        = columnValue[0];
                    gameInfoDTO.GameInfoType  = columnValue[2];
                    gameInfoDTO.GameInfoValue = columnValue[3];

                    GameInfoPersist.CreateGameInfo(gameInfoDTO);
                }
            }
        }
Exemplo n.º 3
0
 void SendGameInfo()
 {
     GameInfoDTO gameInfo = new GameInfoDTO()
     {
         Name     = PlayerInfo.PlayerName,
         GameTime = PlayerInfo.GameTime,
         Level    = PlayerInfo.Level,
     };
     var call = ServerConnector.UpdateAfterGame(gameInfo);
 }
Exemplo n.º 4
0
        private static Game_Info convertToEntity(GameInfoDTO gameInfoDTO)
        {
            var gameInfo = new Game_Info();

            gameInfo.record_id       = gameInfoDTO.RecordID;
            gameInfo.game_id         = gameInfoDTO.GameID;
            gameInfo.game_info_type  = gameInfoDTO.GameInfoType;
            gameInfo.game_info_value = gameInfoDTO.GameInfoValue;

            return(gameInfo);
        }
Exemplo n.º 5
0
    public static async Task <PlayerDTO> UpdateAfterGame(GameInfoDTO gameInfo)
    {
        PlayerDTO           player   = null;
        HttpResponseMessage response = await client.PostAsJsonAsync(
            "players/gameInfo", gameInfo);

        response.EnsureSuccessStatusCode();
        if (response.IsSuccessStatusCode)
        {
            player = await response.Content.ReadAsAsync <PlayerDTO>();
        }

        return(player);
    }