public IHttpActionResult PostProductStock(ProductStock productStock) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.ProductStocks.Add(productStock); try { db.SaveChanges(); } catch (DbUpdateException) { if (ProductStockExists(productStock.ID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = productStock.ID }, productStock); }
public static ProductStock Create(Guid skuID, decimal quantity, decimal weight, Guid departmentID, Guid positionID, string productNumber = "") { ProductStock productStock=new ProductStock(); productStock.SkuID = skuID; productStock.Quantity = quantity; productStock.Weight = weight; productStock.DepartmentID = departmentID; productStock.PositionID = positionID; productStock.ProductNumber = productNumber; return productStock; }
//public virtual Department Department { get; set; } public static ProductStock Create(Guid ownerID, Guid positionID, Guid skuID, string serialNumber, decimal quantity, decimal auxiliaryQuantity) { ProductStock productStock = new ProductStock(); productStock.OwnerID = ownerID; productStock.PositionID = positionID; productStock.ProductSkuID = skuID; productStock.SerialNumber = serialNumber; productStock.AuxiliaryQuantity = auxiliaryQuantity; productStock.Quantity = quantity; return(productStock); }
public IHttpActionResult PutProductStock(Guid id, ProductStock productStock) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != productStock.ID) { return BadRequest(); } db.Entry(productStock).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductStockExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }