Exemple #1
0
        //GetProductId
        public PRODUCT GetProductsId(int id)
        {
            PRODUCT objp = bd.PRODUCTS.FirstOrDefault(p => p.ID == id);

            //object[] arr = ((IEnumerable)objp).Cast<object>()
            //                .Select(x => x.ToString())
            //                .ToArray();
            return(objp);
        }
Exemple #2
0
        //DeleteProducts
        public bool DeleteProducts(int id)
        {
            PRODUCT pro = bd.PRODUCTS.FirstOrDefault(p => p.ID == id);

            if (pro == null)
            {
                return(false);
            }
            else
            {
                bd.PRODUCTS.Remove(pro);
                bd.SaveChanges();
                return(true);
            }
        }
Exemple #3
0
        //UpdateProducts
        public bool UpdateProducts(int id, string des, decimal value)
        {
            PRODUCT Upro = bd.PRODUCTS.FirstOrDefault(p => p.ID == id);

            Upro.DESCRIPTION = des;
            Upro.PRICE       = value;
            if (Upro == null)
            {
                return(false);
            }
            else
            {
                bd.SaveChanges();
                return(true);
            }
        }
Exemple #4
0
        //InsertProducts
        public bool insertProduct(int idPr, string des, decimal value)
        {
            PRODUCT objProducts = new PRODUCT {
                ID = idPr, DESCRIPTION = des, PRICE = value
            };

            if (objProducts == null)
            {
                return(false);
            }
            else
            {
                bd.PRODUCTS.Add(objProducts);
                bd.SaveChanges();
                return(true);
            }
        }