public static void AddCustom(Custom cs) { using (ProteinDBContext db = new ProteinDBContext()) { db.Custom.Add(cs); db.SaveChanges(); } }
public static void Add(Customer customer) { using (ProteinDBContext db = new ProteinDBContext()) { db.Customer.Add(customer); db.SaveChanges(); } }
public static Customer UpdateCustomerInfo(Customer customer) { using (ProteinDBContext db = new ProteinDBContext()) { var uptated = db.Customer.Find(customer.CustomerID); uptated.Name = customer.Name; uptated.Surname = customer.Surname; uptated.Phone = customer.Phone; db.SaveChanges(); return(uptated); } }
static void Main(string[] args) { using (ProteinDBContext db = new ProteinDBContext()) { Admin a = new Admin(); a.UserName = "******"; a.Password = "******"; db.Admin.Add(a); Category c = new Category(); c.CategoryName = "Protein Tozu"; db.Category.Add(c); Brand w = new Brand(); w.BrandName = "Optimum"; db.Brand.Add(w); Product b = new Product() { ProductName = "Optimum Whey", ProductContent = "aaaaa", CategoryID = 1, Price = 230, BrandID = 1, ProductPhoto = "http://placehold.it/800x300", }; db.Product.Add(b); Customer cu = new Customer() { Name = "Hakan Karanfil", Address = "izmir" }; db.Customer.Add(cu); db.SaveChanges(); } }