Exemplo n.º 1
0
        public void CancellaStudente(int id)
        {
            var studente = db.Studenti.Find(id);

            if (studente != null)
            {
                db.Entry(studente).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public void ModificaStudente(Studente studenteModificato)
        {
            /*var studente = db.Studenti.Find(studenteModificato.Id);
             * studente.Nome = studenteModificato.Nome;
             * studente.Cognome = studenteModificato.Cognome;
             * studente.Indirizzo = studenteModificato.Indirizzo; equivale alla riga di codice d.entry*/

            db.Entry(studenteModificato).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
        }