public async Task <IActionResult> Edit([FromForm] Product product)
        {
            //var errors = ModelState
            //    .Where(x => x.Value.Errors.Count > 0)
            //    .Select(x => new { x.Key, x.Value.Errors })
            //    .ToArray();

            if (ModelState.IsValid)
            {
                product.Category = default;
                product.Supplier = default;
                context.Products.Update(product);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View("ProductEditor", ProductViewModelFactory.Edit(product, _categories, _suppliers)));
        }
        public async Task <IActionResult> Edit(long id)
        {
            Product p = await context.Products.FirstOrDefaultAsync(p => p.ProductId == id);

            return(View("ProductEditor", ProductViewModelFactory.Edit(p, _categories, _suppliers)));
        }