public async Task <IActionResult> CreateProduct([FromBody] Production.Product value) { _db.Production_Product.Add(value); await _db.SaveChangesAsync(); return(Ok(value)); }
public async Task <IActionResult> EditProduct(int productID, [FromBody] Production.Product value) { var existing = await _db.Production_Product.FirstOrDefaultAsync(x => x.ProductID == productID); if (existing == null) { return(NotFound()); } existing.ProductID = value.ProductID; existing.Name = value.Name; existing.ProductNumber = value.ProductNumber; existing.MakeFlag = value.MakeFlag; existing.FinishedGoodsFlag = value.FinishedGoodsFlag; existing.Color = value.Color; existing.SafetyStockLevel = value.SafetyStockLevel; existing.ReorderPoint = value.ReorderPoint; existing.StandardCost = value.StandardCost; existing.ListPrice = value.ListPrice; existing.Size = value.Size; existing.SizeUnitMeasureCode = value.SizeUnitMeasureCode; existing.WeightUnitMeasureCode = value.WeightUnitMeasureCode; existing.Weight = value.Weight; existing.DaysToManufacture = value.DaysToManufacture; existing.ProductLine = value.ProductLine; existing.Class = value.Class; existing.Style = value.Style; existing.ProductSubcategoryID = value.ProductSubcategoryID; existing.ProductModelID = value.ProductModelID; existing.SellStartDate = value.SellStartDate; existing.SellEndDate = value.SellEndDate; existing.DiscontinuedDate = value.DiscontinuedDate; existing.rowguid = value.rowguid; existing.ModifiedDate = value.ModifiedDate; _db.Production_Product.Update(existing); await _db.SaveChangesAsync(); return(NoContent()); }