コード例 #1
0
 public static Customer Get(Customer customer)
 {
     using (ProteinDBContext db = new ProteinDBContext())
     {
         return(db.Customer.FirstOrDefault(c => c.Email == customer.Email && c.Password == customer.Password));
     }
 }
コード例 #2
0
 public static Customer GetID(int id)
 {
     using (ProteinDBContext db = new ProteinDBContext())
     {
         return(db.Customer.Find(id));
     }
 }
コード例 #3
0
 public static List <Category> GetAllForHome()
 {
     using (ProteinDBContext db = new ProteinDBContext())
     {
         return(db.Category.ToList());
     }
 }
コード例 #4
0
 public static List <Product> ProductCategory(int id)
 {
     using (ProteinDBContext db = new ProteinDBContext())
     {
         return(db.Product.Where(p => p.CategoryID == id).ToList());
     }
 }
コード例 #5
0
 public static List <Product> GetAllForHome()
 {
     using (ProteinDBContext db = new ProteinDBContext())
     {
         return(db.Product.ToList());
     }
 }
コード例 #6
0
 public static void AddCustom(Custom cs)
 {
     using (ProteinDBContext db = new ProteinDBContext())
     {
         db.Custom.Add(cs);
         db.SaveChanges();
     }
 }
コード例 #7
0
 public static void Add(Customer customer)
 {
     using (ProteinDBContext db = new ProteinDBContext())
     {
         db.Customer.Add(customer);
         db.SaveChanges();
     }
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
        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);
        }
コード例 #10
0
 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());
     }
 }
コード例 #11
0
        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();
            }
        }