public ActiviteDTO GetActivite(int id) { Activite activite = db.Activites.Find(id); if (activite == null) { throw new ArgumentNullException(); } return(activite.toDTO()); }
public IHttpActionResult PostActivite(int JourId, Activite activite) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Activites.Add(activite); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = activite.ActiviteId }, activite.toDTO())); }
public IHttpActionResult DeleteActivite(int id) { Activite activite = db.Activites.Find(id); if (activite == null) { return(NotFound()); } db.Activites.Remove(activite); db.SaveChanges(); return(Ok(activite.toDTO())); }