public ActionResult CreatePurchaseOrders(Inventory item, FormCollection formCollection, string sessionId) { List <int> itemsQuantities = new List <int>(); List <long> itemIds = new List <long>(); string counter = formCollection["counter"]; string empId = EmployeeService.GetUserBySessionId(sessionId).EmpId.ToString(); for (int i = 0; i < int.Parse(counter); i++) { itemsQuantities.Add(int.Parse(formCollection["quantity_" + i])); itemIds.Add(StockService.GetItemId(formCollection["item_" + i])); } List <long> itemsFirstSupplierIds = StockService.GetItemsFirstSupplierIds(itemIds); StockService.CreatePurchaseOrders(empId, itemIds, itemsFirstSupplierIds, itemsQuantities); return(RedirectToAction("All", new { sessionid = sessionId })); }