public async Task <IHttpActionResult> PutAktivitetstype(int id, Aktivitetstype aktivitetstype) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != aktivitetstype.AktivitetstypeID) { return(BadRequest()); } db.Entry(aktivitetstype).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AktivitetstypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetAktivitetstype(int id) { Aktivitetstype aktivitetstype = await db.Aktivitetstype.FindAsync(id); if (aktivitetstype == null) { return(NotFound()); } return(Ok(aktivitetstype)); }
public async Task <IHttpActionResult> PostAktivitetstype(Aktivitetstype aktivitetstype) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Aktivitetstype.Add(aktivitetstype); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = aktivitetstype.AktivitetstypeID }, aktivitetstype)); }
public async Task <IHttpActionResult> DeleteAktivitetstype(int id) { Aktivitetstype aktivitetstype = await db.Aktivitetstype.FindAsync(id); if (aktivitetstype == null) { return(NotFound()); } db.Aktivitetstype.Remove(aktivitetstype); await db.SaveChangesAsync(); return(Ok(aktivitetstype)); }