예제 #1
0
        public PlayerInfo getPlayer(string playername)
        {
            PlayerInfo result = null;
            using (var ctx = new GcmlDbContext())
            {
                PlayerInfo player = (from p in ctx.Players
                    where p.playerName == playername
                    select p).FirstOrDefault();

                if (player == null)
                {
                    player = new PlayerInfo() { playerName = playername };
                    ctx.Players.Add(player);
                    ctx.SaveChanges();
                }

                result = player;
            }

            return result;
        }
예제 #2
0
        public bool safeCampaignState(CampaignController controller)
        {
            bool result = false;
            CampaignState state = controller.CampaignEngine.getState();

            using (var ctx = new GcmlDbContext())
            {
                //var existing = ctx.CampaignStates.Find(state.CampaignId);
                //if (existing == null)
                //{
                //    ctx.CampaignStates.Add(state);
                //}
                //else
                //{
                //    existing = state;
                //}

                ctx.CampaignStates.AddOrUpdate(state);
                ctx.SaveChanges();
                result = true;
            }
            return result;
        }