Example #1
0
        public static void DeleteCustomerPhone(int id)
        {
            Customer_Phone c = db.Customer_Phone.Find(id);

            if (c == null)
            {
                throw new Exception("Sale Not found");
            }

            db.Customer_Phone.Remove(c);

            db.SaveChanges();
        }
Example #2
0
        public static void PutCustomerPhone(int id, ApiCustomerPhone acp)
        {
            // Create a new car
            Customer_Phone cp = db.Customer_Phone.Find(id);

            // Copy car
            if (acp.CustomerPhoneId == id)
            {
                PropertyCopier <ApiCustomerPhone, Customer_Phone> .Copy(acp, cp, true);

                db.Entry(cp).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
        }
Example #3
0
        public static void PostCustomerPhone(ApiCustomerPhone pc)
        {
            // Create a new EF Customer.
            Customer_Phone p = new Customer_Phone();

            // Copy the Simplified customer to the EF customer using the tool I provided.
            PropertyCopier <ApiCustomerPhone, Customer_Phone> .Copy(pc, p, true);

            // Tell EF we want to add the customer.
            db.Customer_Phone.Add(p);

            //Save changes
            db.SaveChanges();
        }