public async Task <IActionResult> Edit(int id, [Bind("Id,ProductCode,Name,Description,Price")] Product product)
        {
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CustomerCode,CustomerType,Name,Web,Email,PhoneNumber")] Customer customer)
        {
            if (id != customer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,SerialNumber,InvoiceNumber,InvoiceDate,SelectedCustomerId")] Invoice invoice)
        {
            if (id != invoice.Id)
            {
                return(NotFound());
            }

            ModelState.Clear();
            var customer = await _context.Customer.FirstOrDefaultAsync(c => c.Id == invoice.SelectedCustomerId);

            if (customer is null)
            {
                ModelState.AddModelError("SelectedCustomerId", "Unable to find customer");
                return(View(invoice));
            }

            invoice.Customer = customer;

            if (ModelState.IsValid)
            {
                try
                {
                    invoice.DueDate = invoice.InvoiceDate.AddDays(DueDays);

                    _context.Update(invoice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InvoiceExists(invoice.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(invoice));
        }