Beispiel #1
0
 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();
     }
 }
Beispiel #2
0
        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;
            }
        }