public async Task <IHttpActionResult> Postcursus(cursus cursus) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.cursus.Add(cursus); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (cursusExists(cursus.CURSUSCODE)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = cursus.CURSUSCODE }, cursus)); }
public async Task <IHttpActionResult> Putcursus(int id, cursus cursus) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cursus.CURSUSCODE) { return(BadRequest()); } db.Entry(cursus).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!cursusExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> Getcursus(int id) { cursus cursus = await db.cursus.FindAsync(id); if (cursus == null) { return(NotFound()); } return(Ok(cursus)); }
public async Task <IHttpActionResult> Deletecursus(int id) { cursus cursus = await db.cursus.FindAsync(id); if (cursus == null) { return(NotFound()); } db.cursus.Remove(cursus); await db.SaveChangesAsync(); return(Ok(cursus)); }