Exemplo n.º 1
0
        public void Update(Product entity, int[] categoriesID)
        {
            var product = _context.Products
                          .Include(x => x.ProductCategories)
                          .Where(x => x.Id == entity.Id)
                          .FirstOrDefault();


            if (product != null)
            {
                product.Name        = entity.Name;
                product.Image       = entity.Image;
                product.Price       = entity.Price;
                product.Description = entity.Description;

                product.ProductCategories = categoriesID.Select(catId => new ProductCategory()
                {
                    CategoryId = catId,
                    ProductId  = entity.Id
                }).ToList();
                _context.SaveChanges();
            }
        }
Exemplo n.º 2
0
 public override void Update(Card entity)
 {
     _context.Cards.Update(entity);
     _context.SaveChanges();
 }