コード例 #1
0
ファイル: ArenaRunRepository.cs プロジェクト: econdie/HSA
        public ArenaRunRepository()
        {
            if (_runs == null)
            {
                _runs = new List<ArenaRun>();
            }

            HSARunsDataContext db = new HSARunsDataContext();
            IEnumerable<zzArenaRun> allRuns = from entries in db.zzArenaRuns select entries;
            foreach(zzArenaRun zzRun in allRuns){

                _runs.Add(new ArenaRun(Convert.ToInt16(zzRun.RunID), Convert.ToInt16(zzRun.Wins), Convert.ToInt16(zzRun.Losses), zzRun.Hero, Convert.ToDateTime(zzRun.RunDate)));
            }
        }
コード例 #2
0
ファイル: ArenaRunAddViewModel.cs プロジェクト: econdie/HSA
        void SaveCommandExecute()
        {
            newRun = new ArenaRunViewModel();
            newRun.Hero = this.NewHero;
            newRun.Wins = this.NewWins;
            newRun.Losses = this.NewLosses;
            newRun.Date = this.NewDate;

            //update DB
            HSARunsDataContext db = new HSARunsDataContext();
            var zzNewRun = new zzArenaRun { Hero = NewHero, Wins = NewWins, Losses = NewLosses, RunDate = NewDate };
            db.zzArenaRuns.InsertOnSubmit(zzNewRun);
            db.SubmitChanges();

            var newPrimaryKey = zzNewRun.RunID;

            newRun.ID = newPrimaryKey;

            MessageBox.Show("Changes have been committed to the database.");

            //update local main view model
            newRunList.Add(newRun);

            mainWindowReference.ViewModel = mainWindowReference;
        }
コード例 #3
0
ファイル: MainWindowViewModel.cs プロジェクト: econdie/HSA
 void DeleteCommandExecute()
 {
     HSARunsDataContext db = new HSARunsDataContext();
     IEnumerable<zzArenaRun> allRuns = from entries in db.zzArenaRuns where entries.RunID == SelectedRun.ID select entries;
     foreach (zzArenaRun zzRun in allRuns)
     {
         db.zzArenaRuns.DeleteOnSubmit(zzRun);
     }
     RunList.Remove(SelectedRun);
     db.SubmitChanges();
 }
コード例 #4
0
ファイル: ArenaRunEditViewModel.cs プロジェクト: econdie/HSA
        void SaveCommandExecute()
        {
            //update DB
            HSARunsDataContext db = new HSARunsDataContext();
            IEnumerable<zzArenaRun> allRuns = from entries in db.zzArenaRuns where entries.RunID == EditedArenaRun.ID select entries;
            foreach (zzArenaRun zzRun in allRuns)
            {
                zzRun.Wins = EditedWins;
                zzRun.Losses = EditedLosses;
                zzRun.Hero = EditedHero;
                zzRun.RunDate = EditedDate;
            }
            db.SubmitChanges();

            MessageBox.Show("Changes have been committed to the database.");

            //update local main view model
            EditedArenaRun.Wins = EditedWins;
            EditedArenaRun.Losses = EditedLosses;
            EditedArenaRun.Hero = EditedHero;
            EditedArenaRun.Date = EditedDate;

            mainWindowReference.ViewModel = mainWindowReference;
        }