コード例 #1
0
ファイル: Cleaner.cs プロジェクト: QuickUnit/PacmanTlv
 public static void Clear()
 {
     using (var sqlConnection = new SqlConnection(new ConnectionStringProvider().GetConnectionString()))
     using (var pacManDataContext = new PacManDataContext(sqlConnection))
     {
         pacManDataContext.Games.DeleteAllOnSubmit(pacManDataContext.Games);
         pacManDataContext.Entities.DeleteAllOnSubmit(pacManDataContext.Entities);
         pacManDataContext.Orders.DeleteAllOnSubmit(pacManDataContext.Orders);
         pacManDataContext.SubmitChanges();
     }
 }
コード例 #2
0
ファイル: PlayersStorage.cs プロジェクト: QuickUnit/PacmanTlv
        public Player UpdateEntity(int entityId, bool isEnabled, double geoLat, double geoLng)
        {
            using (var dbConnection = _ConnectionProvider.GetConnection())
            using (var pacManDataContext = new PacManDataContext(dbConnection))
            {
                var dataLoadOptions = new DataLoadOptions();
                dataLoadOptions.LoadWith<Player>(x => x.Game);
                pacManDataContext.LoadOptions = dataLoadOptions;

                var updateEntity = pacManDataContext
                    .Players
                    .Where(x => x.Id == entityId)
                    .First();
                updateEntity.State = (int)(isEnabled?PlayerState.JoinedActivePlaying:PlayerState.JoinedDisabled);
                updateEntity.LastGeoLat = geoLat;
                updateEntity.LastGeoLon = geoLng;
                updateEntity.LastCommunicationAt = DateTime.Now;

                pacManDataContext.SubmitChanges();

                return updateEntity;
            }
        }