public ArenaRunEditViewModel(ArenaRunViewModel arenaRun, MainWindowViewModel mainWindow) { this.EditedArenaRun = arenaRun; this.EditedWins = arenaRun.Wins; this.EditedLosses = arenaRun.Losses; this.EditedHero = arenaRun.Hero; this.EditedDate = arenaRun.Date; this.mainWindowReference = mainWindow; }
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; }