Kaffeplaneten.DAL.ProductDAL.Delete C# (CSharp) Method

Delete() public method

public Delete ( int id ) : bool
id int
return bool
        public bool Delete(int id)
        {
            using (var db = new CustomerContext())
            {
                try
                {
                    Products slett = (from p in db.Products where p.productID == id select p).Single();
                    db.Products.Remove(slett);
                    db.SaveChanges();
                    return true;

                }
                catch (Exception ex)
                {
                    _logging.logToDatabase(ex);
                }
            }
            return false;
        }