示例#1
0
 public bool AddCustomer(WebServiceAssigment2.Models.DataModels.Customer customer)
 {
     try
     {
         db.Customers.Add(customer);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#2
0
        public bool UpdateCustomer(WebServiceAssigment2.Models.DataModels.Customer customer)
        {
            var cs = db.Customers.Find(customer.ID);

            db.Customers.Remove(cs);
            db.Customers.Add(customer);
            db.SaveChanges();
            //db.Entry(customer).State = EntityState.Modified;
            //db.SaveChanges();
            return(true);

            //var user = db.Users.Where(x => x.ID == us.ID).First();
            //db.Users.Remove(user);
            //db.Users.Add(us);
            //db.SaveChanges();
            //return true;
        }