public static int AddUserData(All userData) { UserBuild ub = new UserBuild(); userData.Time = Function.GetUTCTime(); SamgoModels.UserInfo ui = new SamgoModels.UserInfo(); UserValue uLord = new UserValue(); UserValue uProsperity = new UserValue(); UserPower up = new UserPower(); UserTechnique ut = new UserTechnique(); UserOrdnance uo = new UserOrdnance(); var userInfo = new SamgoModels.UserInfo(); userData.SeqNo = DapperHelper.Search<int>( connectionString, " exec [samgo_add_user_and_group] N'" + userData.Role + "' , N'" + userData.Legion + "'").FirstOrDefault(); ConvertDataToModels(ref ub, ref ui, ref uLord, ref uProsperity, ref up, userData); DapperHelper.InsertSQLNormal<UserBuild>(connectionString, "Build", ub); //DapperHelper.InsertSQL<SamgoModels.UserInfo>(connectionString, "SamgoGame", ui); DapperHelper.InsertSQLNormal<UserValue>(connectionString, "Lord", uLord); DapperHelper.InsertSQLNormal<UserValue>(connectionString, "Prosperity", uProsperity); DapperHelper.InsertSQLNormal<UserPower>(connectionString, "SamgoGamePower", up); ConvertDataToModels(ref ut, ref uo, userData); DapperHelper.InsertSQLNormal<UserTechnique>(connectionString, "Technique", ut); var response = DapperHelper.InsertSQLNormal<UserOrdnance>(connectionString, "Ordnance", uo); return userData.SeqNo; }
private static void ConvertDataToModels(ref UserBuild ub, ref SamgoModels.UserInfo ui, ref UserValue uLord, ref UserValue uProsperity, ref UserPower up, All userData) { //SamgoGame(主紀錄+編號) ui.Legion = userData.Legion; ui.Official = userData.Official; ui.Role = userData.Role; ui.SeqNo = userData.SeqNo; //Lord(主公) uLord.SeqNo = userData.SeqNo; uLord.Time = userData.Time; uLord.Value = userData.Lord; //Prosperity(繁榮) uProsperity.SeqNo = userData.SeqNo; uProsperity.Time = userData.Time; uProsperity.Value = userData.Prosperity; //Build(大殿) ub.SeqNo = userData.SeqNo; ub.Time = userData.Time; ub.Basilica = userData.Basilica; ub.Technique = userData.Technique; ub.Market = userData.Market; ub.Horse = userData.Horse; ub.School = userData.School; ub.House = userData.House; ub.Wood = userData.Wood; ub.Stone = userData.Stone; ub.Iron = userData.Iron; ub.Farmland = userData.Farmland; ub.Barracks = userData.Barracks; ub.Soldier = userData.Soldier; ub.Coin = userData.Coin; ub.Treasure = userData.Treasure; ub.Ordnance = userData.Ordnance; ub.Wall = userData.Wall; //戰力 up.Power = userData.Power; up.SeqNo = userData.SeqNo; up.Time = userData.Time; }