public async Task <IActionResult> Create([Bind("PowderOrderId,PurchaseOrderNum,PurchaseOrderDate,ShippingCost,TaxCost,VendorId,NumberOfLineItems")] PowderOrder powderOrder)
        {
            if (powderOrder.NumberOfLineItems == null || powderOrder.NumberOfLineItems <= 0)
            {
                ViewBag.NoLineItems  = true;
                ViewData["VendorId"] = new SelectList(await _repo.GetAllVendors(), "VendorId", "VendorName", powderOrder.VendorId);
                return(View(powderOrder));
            }

            if (ModelState.IsValid)
            {
                powderOrder.PowderOrderId = Guid.NewGuid();
                SetUIDs();
                await _repo.AddPowderOrder(powderOrder);

                List <LineItem> lineItems = new List <LineItem>();
                for (int i = 0; i < powderOrder.NumberOfLineItems; i++)
                {
                    var lineItem = new LineItem()
                    {
                        LineItemId        = Guid.NewGuid(),
                        PowderOrder       = powderOrder,
                        PowderOrderId     = powderOrder.PowderOrderId,
                        VendorDescription = "",
                        Weight            = 0,
                        LineItemCost      = 0.0f,
                        ParticleSizeMin   = 0.0f,
                        ParticleSizeMax   = 0.0f,
                    };
                    lineItems.Add(lineItem);
                }
                SetUIDs();
                await _repo.AddLineItems(lineItems);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VendorId"] = new SelectList(await _repo.GetAllVendors(), "VendorId", "VendorName", powderOrder.VendorId);
            return(View(powderOrder));
        }