public async Task <IHttpActionResult> PutPositionProduct(int id, PositionProduct positionProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != positionProduct.Id) { return(BadRequest()); } db.Entry(positionProduct).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PositionProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetPositionProduct(int id) { PositionProduct positionProduct = await db.PositionProduct.FindAsync(id); if (positionProduct == null) { return(NotFound()); } return(Ok(positionProduct)); }
public async Task <IHttpActionResult> PostPositionProduct(PositionProduct positionProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PositionProduct.Add(positionProduct); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = positionProduct.Id }, positionProduct)); }
public async Task <IHttpActionResult> DeletePositionProduct(int id) { PositionProduct positionProduct = await db.PositionProduct.FindAsync(id); if (positionProduct == null) { return(NotFound()); } db.PositionProduct.Remove(positionProduct); await db.SaveChangesAsync(); return(Ok(positionProduct)); }