public IHttpActionResult PutActiviter(int id, Activiter activiter) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != activiter.id_activiter) { return(BadRequest()); } db.Entry(activiter).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ActiviterExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostActiviter(Activiter activiter) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Activiter.Add(activiter); try { db.SaveChanges(); } catch (DbUpdateException) { if (ActiviterExists(activiter.id_activiter)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = activiter.id_activiter }, activiter)); }
public IHttpActionResult DeleteActiviter(int id) { Activiter activiter = db.Activiter.Find(id); if (activiter == null) { return(NotFound()); } db.Activiter.Remove(activiter); db.SaveChanges(); return(Ok(activiter)); }