public IActionResult Post([FromBody] EntityVendingMachine entityVending) { List <EntityProductStock> productStocks = new List <EntityProductStock>(); var ProductMachines = _context.ProductMachines .Include(p => p.Product) .Include(m => m.Machine) .Where(m => m.MachineId == entityVending.machineSerial) .ToList(); ProductMachines.ForEach(pm => { productStocks.Add(new EntityProductStock { productMachineIndex = pm.ProductMachineIndex, productMachineQty = pm.ProductMachineQty }); }); return(new ObjectResult(new Response(productStocks, true))); }
public IActionResult SendPendingProducts([FromBody] EntityVendingMachine machine) { List <EntityReleaseProduct> ReleaseProducts = new List <EntityReleaseProduct>(); var pendingCommands = _context.PendingCommands .Include(p => p.ProductMachine) .ThenInclude(m => m.Machine) .Where(m => m.status == 0 && m.ProductMachine.MachineId == machine.machineSerial) .ToList(); foreach (PendingCommand p in pendingCommands) { ReleaseProducts.Add(new EntityReleaseProduct { machineSerial = p.ProductMachine.MachineId, index = p.ProductMachine.ProductMachineIndex, status = p.status }); } return(Json(new Response(ReleaseProducts, true))); }