public async Task <IActionResult> Initialize([Bind("LineItemId,StaticPowderInfoId,VendorDescription,Weight,LineItemCost,ParticleSizeMin,ParticleSizeMax,PowderOrderId,NumBottles,CertPdfFile")] LineItem lineItem) { lineItem.StaticPowderInfo = await _repo.GetStaticPowderInfo((Guid)lineItem.StaticPowderInfoId); if (lineItem.CertPdfFile != null) { lineItem.CertPdfBytes = await FileURL.GetFileBytes(lineItem.CertPdfFile); } SetUIDs(); await _repo.UpdateLineItem(lineItem); List <PowderBottle> bottles = new List <PowderBottle>(); for (int i = 0; i < lineItem.NumBottles; i++) { bottles.Add(new PowderBottle { PowderBottleId = Guid.NewGuid(), BottleNumber = "", LotNumber = "", InitWeight = 0, Weight = 0, LineItem = lineItem, LineItemId = lineItem.LineItemId, StaticPowderInfo = lineItem.StaticPowderInfo, StaticPowderInfoId = lineItem.StaticPowderInfo.StaticPowderInfoId }); } SetUIDs(); await _repo.AddPowderBottles(bottles); lineItem.PowderOrder = await _repo.GetPowderOrder(lineItem.PowderOrderId); return(RedirectToAction("Index", "LineItems", new { powderOrderId = lineItem.PowderOrderId })); }