public void Insert(ProductDataContract product)
 {
     using (var context = new Entity.PagueMenosEntities())
     {
         var newProduct = new Entity.gtin();
         newProduct.GTIN_CD       = product.Code;
         newProduct.GTIN_LEVEL_CD = int.Parse(product.Code);
         newProduct.GTIN_NM       = product.Name;
         newProduct.PKG_UNIT      = product.Unity;
         newProduct.M_ML          = product.Volume;
         newProduct.M_G           = product.Weight;
         newProduct.SOURCE        = DefaultSource;
         context.gtin.Add(newProduct);
         context.SaveChanges();
     }
 }
        public bool Delete(string code)
        {
            using (var context = new Entity.PagueMenosEntities())
            {
                var existing = context.gtin.SingleOrDefault(p => p.GTIN_CD == code);

                if (existing != null)
                {
                    context.gtin.Remove(existing);
                    context.SaveChanges();

                    return(true);
                }
            }

            return(false);
        }
        public bool Update(ProductDataContract product)
        {
            using (var context = new Entity.PagueMenosEntities())
            {
                var existing = context.gtin.SingleOrDefault(p => p.GTIN_CD == product.Code);

                if (existing != null)
                {
                    existing.GTIN_CD  = product.Code;
                    existing.GTIN_NM  = product.Name;
                    existing.PKG_UNIT = product.Unity;
                    existing.M_ML     = product.Volume;
                    existing.M_G      = product.Weight;
                    existing.SOURCE   = DefaultSource;
                    context.SaveChanges();

                    return(true);
                }
            }

            return(false);
        }