Ejemplo n.º 1
0
        public static void Delete(int id)
        {
            var      context = new HondaDBContext();
            Customer c       = context.Customers.Find(id);

            context.Customers.Remove(c);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void AddCustomer(Customer c)
        {
            //create db
            HondaDBContext context = new HondaDBContext();

            //add customer c to database
            context.Customers.Add(c);
            //save changes
            context.SaveChanges();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// adds a Vehical Object to the dataBase
        /// </summary>
        /// <param name="v"></param>
        public static void AddVehicle(Vehicle v)
        {
            //creates db context
            HondaDBContext context = new HondaDBContext();

            //adds the the object to database
            context.Vehicles.Add(v);
            //saves the changes
            context.SaveChanges();
        }
Ejemplo n.º 4
0
        //public static bool CheckForCustomerID(int id)
        //{
        //	HondaDBContext context = new HondaDBContext();
        //	try
        //	{
        //		context.Customers.Find(id);
        //	}
        //}

        public static void Update(Customer c)
        {
            HondaDBContext context = new HondaDBContext();

            //tell EF this product has only been modified
            //its already in the db
            context.Entry(c).State = EntityState.Modified;

            //sends update query to the database
            context.SaveChanges();
        }