예제 #1
0
 public void SaveMessage(Message message)
 {
     using (EntityConnection connection = new EntityConnection("name=CoreContainer"))
     {
         _core = new CoreContainer(connection);
         _core.Messages.AddObject(message);
         _core.SaveChanges();
     }
 }
예제 #2
0
        public Event SaveNewEvent(Event comp)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Events.AddObject(comp);
                _core.SaveChanges();
            }

            return comp;
        }
예제 #3
0
        public Series SaveNewSeries(Series series)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Series.AddObject(series);
                _core.SaveChanges();
            }

            return series;
        }
예제 #4
0
        public Location SaveNewLocation(Location location)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Locations.AddObject(location);
                _core.SaveChanges();
            }

            return location;
        }
예제 #5
0
        public void DeleteResult(Result result)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                string query = string.Format("delete from Result where ResultId = {0}", result.ResultId);

                _core.ExecuteStoreCommand(query);

                _core.SaveChanges();
            }
        }
예제 #6
0
        public Event UpdateEvent(Event comp)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Events.Attach(_core.Events.Single(s => s.EventId == comp.EventId));

                _core.Events.ApplyCurrentValues(comp);

                _core.SaveChanges();
            }

            return comp;
        }
예제 #7
0
        public Location UpdateLocation(Location location)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Locations.Attach(_core.Locations.Single(l => l.LocationId == location.LocationId));

                _core.Locations.ApplyCurrentValues(location);

                _core.SaveChanges();
            }

            return location;
        }
예제 #8
0
        public void UpdateScores(IList<Score> scores)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                foreach (var score in scores)
                {
                    _core.Scores.Attach(_core.Scores.Single(s => s.ScoreId == score.ScoreId));

                    _core.Scores.ApplyCurrentValues(score);

                    _core.SaveChanges();
                }
            }
        }
예제 #9
0
        public void DeleteScores(EntityCollection<Score> scores)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                foreach (var score in scores)
                {
                    string query = string.Format("delete from Score where ScoreId = {0}", score.ScoreId);

                    _core.ExecuteStoreCommand(query);
                }

                _core.SaveChanges();
            }
        }
예제 #10
0
        public Driver UpdateDriver(Driver driver)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Drivers.Attach(_core.Drivers.Single(c => c.DriverId == driver.DriverId));

                _core.Drivers.ApplyCurrentValues(driver);

                _core.SaveChanges();
            }

            return driver;
        }
예제 #11
0
        public Driver SaveNewDriver(Driver driver)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Drivers.AddObject(driver);
                _core.SaveChanges();
            }

            return driver;
        }
예제 #12
0
        public IList<Result> UpdateResultSet(IList<Result> results)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                foreach(var result in results)
                {
                    _core.Results.Attach(_core.Results.Single(r => r.ResultId == result.ResultId));

                    _core.Results.ApplyCurrentValues(result);

                    _core.SaveChanges();
                }
            }

            return results;
        }
예제 #13
0
        public void SaveNewScores(Result result)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Results.AddObject(result);
                _core.SaveChanges();
            }
        }
예제 #14
0
        public Club UpdateClub(Club club)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Clubs.Attach(_core.Clubs.Single(c => c.ClubId == club.ClubId));

                _core.Clubs.ApplyCurrentValues(club);

                _core.SaveChanges();
            }

            return club;
        }
예제 #15
0
        public Club SaveNewClub(Club club)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Clubs.AddObject(club);
                _core.SaveChanges();
            }

            return club;
        }
예제 #16
0
        public Series UpdateSeries(Series series, IList<SeriesClass> newClasses)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Series.Attach(_core.Series.Include("SeriesClasses").Single(s => s.SeriesId == series.SeriesId));

                _core.Series.ApplyCurrentValues(series);

                if (series.SeriesClasses != null && series.SeriesClasses.Count > 0)
                {
                    foreach (var oldClass in series.SeriesClasses)
                    {
                        string query = string.Format("delete from SeriesClass where SeriesClassId = {0}", oldClass.SeriesClassId);

                        _core.ExecuteStoreCommand(query);
                    }
                }

                var saveSeries = _core.Series.Single(s => s.SeriesId == series.SeriesId);

                foreach (var selectedClass in newClasses)
                {
                    saveSeries.SeriesClasses.Add(new SeriesClass{ClassId = selectedClass.ClassId, SeriesId = selectedClass.SeriesId});
                }

                _core.SaveChanges();
            }

            return series;
        }