Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
        //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);
        }
Exemplo n.º 4
0
        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);
        }