public IHttpActionResult PostpostnrBy(postnrBy postnrBy) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.postnrBy.Add(postnrBy); try { db.SaveChanges(); } catch (DbUpdateException) { if (postnrByExists(postnrBy.Postnr)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = postnrBy.Postnr }, postnrBy)); }
public IHttpActionResult PutpostnrBy(int id, postnrBy postnrBy) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != postnrBy.Postnr) { return(BadRequest()); } db.Entry(postnrBy).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!postnrByExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetpostnrBy(int id) { postnrBy postnrBy = db.postnrBy.Find(id); if (postnrBy == null) { return(NotFound()); } return(Ok(postnrBy)); }
public IHttpActionResult DeletepostnrBy(int id) { postnrBy postnrBy = db.postnrBy.Find(id); if (postnrBy == null) { return(NotFound()); } db.postnrBy.Remove(postnrBy); db.SaveChanges(); return(Ok(postnrBy)); }