public IActionResult Put(int id, [FromBody] CorsoAllievo value)
        {
            try
            {
                CorsoAllievo daAggiornare = context.CorsiAllievi.Find(id);
                if (daAggiornare == null)
                {
                    //return NotFound();
                }
                daAggiornare.IdAllievo       = value.IdAllievo;
                daAggiornare.IdEdizioneCorso = value.IdEdizioneCorso;
                daAggiornare.Voto            = value.Voto;

                //value.IdCorso = id;
                //context.Corsi.Update(value);
                context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException e)
            {
                return(NotFound(new BusinessLogicException("Elemento non trovato", e)));
            }
            catch (Exception e)
            {
                return(BadRequest(new BusinessLogicException("Errore ", e)));
            }
            return(Ok(value));
        }
예제 #2
0
 public void Save()
 {
     try
     {
         ctx.SaveChanges();
     }
     catch (DbUpdateConcurrencyException e)
     {
         throw new DataException("errore nella update, elmento non esistente", e);
     }
 }
예제 #3
0
 public void Save()
 {
     ctx.SaveChanges();
 }