Exemplo n.º 1
0
        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)));
            }
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
        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;
        }