Exemplo n.º 1
0
        public static void CreateAdminInfo(AdminInfoDTO adminInfoDTO)
        {
            // ballpark instance of Player class in Retrosheet_Persist.Retrosheet
            var adminInfo = convertToEntity(adminInfoDTO);

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

            dbCtx.Admin_Info.Add(adminInfo);

            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 ReadWriteAdminInfoFile()
        {
            string[] columnValue;
            string   textLine = null;

            using (StreamReader reader = new StreamReader(@"C:\users\mmr\documents\retrosheet\2016 Regular Season\Output\2016SLN\2016SLN_admininfo"))
            {
                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_admininfo" + " file could not be read:");
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }

                    columnValue = textLine.Split('|');

                    AdminInfoDTO adminInfoDTO = new AdminInfoDTO();

                    adminInfoDTO.RecordID       = Guid.NewGuid();
                    adminInfoDTO.GameID         = columnValue[0];
                    adminInfoDTO.AdminInfoType  = columnValue[2];
                    adminInfoDTO.AdminInfoValue = columnValue[3];

                    AdminInfoPersist.CreateAdminInfo(adminInfoDTO);
                    Console.WriteLine(textLine);
                }
            }
        }
Exemplo n.º 3
0
        private static Admin_Info convertToEntity(AdminInfoDTO adminInfoDTO)
        {
            var adminInfo = new Admin_Info();

            adminInfo.record_id       = adminInfoDTO.RecordID;
            adminInfo.game_id         = adminInfoDTO.GameID;
            adminInfo.admin_info_type = adminInfoDTO.AdminInfoType;
            adminInfo.admin_inf_value = adminInfoDTO.AdminInfoValue;

            return(adminInfo);
        }