public IHttpActionResult PostvProductAndDescription(vProductAndDescription vProductAndDescription) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.vProductAndDescriptions.Add(vProductAndDescription); try { db.SaveChanges(); } catch (DbUpdateException) { if (vProductAndDescriptionExists(vProductAndDescription.ProductID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = vProductAndDescription.ProductID }, vProductAndDescription); }
public IHttpActionResult PutvProductAndDescription(int id, vProductAndDescription vProductAndDescription) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != vProductAndDescription.ProductID) { return BadRequest(); } db.Entry(vProductAndDescription).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!vProductAndDescriptionExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }