//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); }
//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); } }
//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); } }
//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); } }