public int Update(Category category)
 {
     Category dbCategory;
     var result = -1;
     using (_dbContext = new ProductsEntities())
     {
         dbCategory = _dbContext.Categories.FirstOrDefault(p => p.ID == category.ID);
     }
     if (dbCategory != null)
     {
         MapCategory(dbCategory, category);
         using (_dbContext = new ProductsEntities())
         {
             _dbContext.Entry(category).State = System.Data.Entity.EntityState.Modified;
             result = _dbContext.SaveChanges();
         }
     }
     return result;
 }
 public int Update(Product product)
 {
     Product dbProduct;
     var result = -1;
     using (_dbContext = new ProductsEntities())
     {
         dbProduct = _dbContext.Products.FirstOrDefault(p => p.ID == product.ID);
     }
     if (dbProduct != null)
     {
         MapProduct(dbProduct, product);
         using (_dbContext = new ProductsEntities())
         {
             _dbContext.Entry(product).State = System.Data.Entity.EntityState.Modified;
             result = _dbContext.SaveChanges();
         }
     }
     return result;
 }