Ejemplo n.º 1
0
        private async void FillDataGridViewProducsAsync()
        {
            IRepositoryGeneric <Product> repositoryProducts = new RepositoryProduct();
            List <Product> products = await repositoryProducts.SelectAll();

            List <ProductsViewModel> productsViewModels = new List <ProductsViewModel>();

            foreach (Product product in products)
            {
                ProductsViewModel viewModel = new ProductsViewModel
                {
                    Id      = product.Id,
                    BrandId = product.BrandId,
                    Brand   = product.Brand.Name,
                    Name    = product.Name
                };
                productsViewModels.Add(viewModel);
            }
            dgvProducts.Invoke((MethodInvoker) delegate
            {
                dgvProducts.DataSource = productsViewModels;
                dgvProducts.Refresh();
            });
        }