public IHttpActionResult PutHorari(int id, Horari horari) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != horari.id) { return(BadRequest()); } db.Entry(horari).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HorariExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetHorari(int id) { Horari horari = db.Horari.Find(id); if (horari == null) { return(NotFound()); } return(Ok(horari)); }
public IHttpActionResult PostHorari(Horari horari) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Horari.Add(horari); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = horari.id }, horari)); }
public IHttpActionResult DeleteHorari(int id) { Horari horari = db.Horari.Find(id); if (horari == null) { return(NotFound()); } db.Horari.Remove(horari); db.SaveChanges(); return(Ok(horari)); }