public static Customer Get(Customer customer) { using (ProteinDBContext db = new ProteinDBContext()) { return(db.Customer.FirstOrDefault(c => c.Email == customer.Email && c.Password == customer.Password)); } }
public static Customer GetID(int id) { using (ProteinDBContext db = new ProteinDBContext()) { return(db.Customer.Find(id)); } }
public static List <Category> GetAllForHome() { using (ProteinDBContext db = new ProteinDBContext()) { return(db.Category.ToList()); } }
public static List <Product> ProductCategory(int id) { using (ProteinDBContext db = new ProteinDBContext()) { return(db.Product.Where(p => p.CategoryID == id).ToList()); } }
public static List <Product> GetAllForHome() { using (ProteinDBContext db = new ProteinDBContext()) { return(db.Product.ToList()); } }
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); } }
public static List <Product> ProductSearch(string search) { var response = new List <Product>(); if (string.IsNullOrEmpty(search) == false) { using (ProteinDBContext db = new ProteinDBContext()) { return(db.Product.Where(p => p.ProductName.Contains(search) || p.Category.CategoryName.Contains(search)).ToList()); } } return(response); }
public static ViewProductForDetails Get(int id) { using (ProteinDBContext db = new ProteinDBContext()) { return(db.Product.Where(b => b.ProductID == id) .Select(b => new ViewProductForDetails { ProductID = b.ProductID, Brand = b.Brand.BrandName, ProductName = b.ProductName, Price = b.Price, ProductContent = b.ProductContent, ProductPhoto = b.ProductPhoto, }).FirstOrDefault()); } }
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(); } }