public async Task <ActionResult <Shipment> > AddShipment([FromBody] Shipment s1) { var seller = await _context.Seller.FindAsync(s1.SellerId); var product = await _context.Product.FindAsync(s1.ProductId); if (seller == null || product == null) { return(null); } var IsAvail = seller.IsAvailable; var Quantity = product.ProductQuantity; if (Quantity >= s1.Quantity && IsAvail == "Yes") { s1.Status = "Approved"; product.ProductQuantity -= s1.Quantity; seller.IsAvailable = "No"; } else { s1.Status = "Cancelled"; } await _context.Shipment.AddAsync(s1); await _context.SaveChangesAsync(); return(s1); }
public async Task <ActionResult <Product> > AddProduct(Product p1) { await _context.Product.AddAsync(p1); await _context.SaveChangesAsync(); return(p1); }
public async Task <ActionResult <Seller> > AddSeller([FromBody] Seller s1) { await _context.Seller.AddAsync(s1); await _context.SaveChangesAsync(); return(s1); }