public async Task <IHttpActionResult> PutAttributeProduct(int id, AttributeProduct attributeProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != attributeProduct.Id) { return(BadRequest()); } db.Entry(attributeProduct).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AttributeProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetAttributeProduct(int id) { AttributeProduct attributeProduct = await db.AttributeProduct.FindAsync(id); if (attributeProduct == null) { return(NotFound()); } return(Ok(attributeProduct)); }
public async Task <IHttpActionResult> PostAttributeProduct(AttributeProduct attributeProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AttributeProduct.Add(attributeProduct); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = attributeProduct.Id }, attributeProduct)); }
public async Task <IHttpActionResult> DeleteAttributeProduct(int id) { AttributeProduct attributeProduct = await db.AttributeProduct.FindAsync(id); if (attributeProduct == null) { return(NotFound()); } db.AttributeProduct.Remove(attributeProduct); await db.SaveChangesAsync(); return(Ok(attributeProduct)); }