public void addScore(string _jogador, int _pontos) { using (tragacervejasdbEntities bd = new tragacervejasdbEntities()) { if (_jogador != null && _pontos != null) { jogo j = new jogo(); j.jogador = _jogador; j.pontos = _pontos; j.dia = DateTime.Now; bd.jogos.Add(j); //bd.Entry(j).State = j.id == 0 ? System.Data.Entity.EntityState.Added : System.Data.Entity.EntityState.Modified; //var teste = bd.Set<jogo> //bd.jogos.At //bd.jogos.Attach(j); bd.SaveChanges(); reset(); } System.Windows.MessageBox.Show(String.Format("Pontos: {0}", _pontos.ToString())); } //reset(); }
public void reset() { using (tragacervejasdbEntities bd = new tragacervejasdbEntities()) { ListaJogos = new ObservableCollection <jogo>(bd.jogos); JogosView = CollectionViewSource.GetDefaultView(ListaJogos); JogoCorrente = (jogo)JogosView.CurrentItem; } }