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();
            }
        }
Esempio n. 2
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();
            }
        }
        public Series DeleteAllSeriesClasses(Series series)
        {
            foreach (var seriesClass in series.SeriesClasses)
            {
                using (var connection = new EntityConnection("name=CoreContainer"))
                {
                    _core = new CoreContainer(connection);

                    string query = string.Format("delete from SeriesClass where SeriesClassId = {0}", seriesClass.SeriesClassId);

                    _core.ExecuteStoreCommand(query);
                }
            }

            return series;
        }
        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;
        }