public IActionResult Inserisci(Allievo allievo) { if (ModelState.IsValid) { repo.Add(allievo); return(RedirectToAction("Inserisci", "Allievi/Index")); } return(View(allievo)); }
public static AllievoDTO ToDTO(this Allievo allievo) { return(new AllievoDTO { IdStudente = allievo.IdStudente, Nome = allievo.Nome, CodiceFiscale = allievo.CodiceFiscale, Cognome = allievo.Cognome, TipoStudente = allievo.TipoStudente }); }
public IActionResult Crea([FromBody] AllievoDTO studDTO) { if (studDTO == null) { return(BadRequest()); } Allievo stud = studDTO.ToAllievo(); work.Begin(); work.AllieviRepo.Add(stud); work.Save(); work.End(); return(CreatedAtRoute(ROUTE_GET_ALLIEVI, new { id = stud.IdStudente }, stud.ToDTO())); //risp al client }
public IActionResult Get(int id) { if (id < 1) { return(BadRequest()); } Allievo stud = work.AllieviRepo.Find(id); if (stud == null) { return(NotFound()); } return(Ok(stud.ToDTO())); }
public IActionResult Update([FromBody] AllievoDTO studDTO) { if (studDTO == null) { return(BadRequest()); } Allievo doc = studDTO.ToAllievo(); try { work.Begin(); work.AllieviRepo.Update(doc); work.Save(); work.End(); } catch (DataException) { return(NotFound()); } return(NoContent()); }
static void Main(string[] args) { Console.Clear(); //Console.WriteLine("Hello World!"); var d = new Docente("DINO", "risi"); d.Scrivi(); d.nome = "daniele"; d.cognome = "GOBBO"; d.materia = "Informatica"; d.Scrivi(); var a = new Allievo("g", "g"); a.Scrivi(); var p = new Persona(); p.Scrivi(); p = d; d.nome = "Lazzaro"; p.Scrivi(); p.nome = "Arnaldo"; d = (Docente)p; d.Scrivi(); }
public void Update(Allievo stud) { throw new NotImplementedException(); }
public void Add(Allievo Studente) { listaAllievi.Add(Studente); }
public void Update(Allievo studente) { context.Allievi.Update(studente); }
public void Add(Allievo Studente) { context.Allievi.Add(Studente); context.SaveChanges(); }