Esempio n. 1
0
 public void Delete(Admin admin)
 {
     using (TechContext context = new TechContext())
     {
         var entity = context.Entry(admin);
         entity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Esempio n. 2
0
 public void Add(Category category)
 {
     using (TechContext context = new TechContext())
     {
         var entity = context.Entry(category);
         entity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Esempio n. 3
0
 public void Update(Brand brand)
 {
     using (TechContext context = new TechContext())
     {
         var entity = context.Entry(brand);
         entity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void UserUpdate(User user)
 {
     using (TechContext context = new TechContext())
     {
         var entity = context.Entry(user);
         entity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void Add(Message message)
 {
     using (TechContext context = new TechContext())
     {
         var entity = context.Entry(message);
         entity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Esempio n. 6
0
        public List <Brand> GetBrandsName()
        {
            using (TechContext context = new TechContext())
            {
                var brandsList = context.Brands.ToList();

                return(brandsList);
            }
        }
Esempio n. 7
0
        public List <Category> LatestCategories(int piece)
        {
            using (TechContext context = new TechContext())
            {
                var latestCategories = (from category in context.Categories
                                        orderby category.CategoryID descending select category).Take(piece).ToList();

                return(latestCategories);
            }
        }
Esempio n. 8
0
 public List <Product> JoinProducts(string brandName)
 {
     using (TechContext context = new TechContext())
     {
         var productList = (from i in context.Products
                            join brand in context.Brands on i.BrandID equals brand.BrandID
                            where brandName.Contains(brand.BrandName)
                            select i).ToList();
         return(productList);
     }
 }
Esempio n. 9
0
        public List <Brand> LatestBrands(int piece)
        {
            using (TechContext context = new TechContext())
            {
                var latestBrands = (from i in context.Brands
                                    orderby i.BrandID descending
                                    select i).Take(piece).ToList();

                return(latestBrands);
            }
        }
Esempio n. 10
0
        public int GetID(string brandName)
        {
            int ID = 0;

            using (TechContext context = new TechContext())
            {
                var brandID = (from brand in context.Brands where brand.BrandName == brandName select brand.BrandID);
                foreach (var i in brandID)
                {
                    ID += i;
                }

                return(ID);
            }
        }
Esempio n. 11
0
        public int GetId(string username)
        {
            int Id = 0;

            using (TechContext context = new TechContext())
            {
                var adminId = context.Admins.Where(p => p.Username == username);
                foreach (var admin in adminId)
                {
                    Id += admin.Id;
                }

                return(Id);
            }
        }
        public string Login(string username, string password)
        {
            using (TechContext context = new TechContext())
            {
                var userList = context.Users.Where(p => p.UserName == username & p.Password == password).ToList();
                if (userList.Count > 0)
                {
                    return("Giriş başarılı");
                }

                else
                {
                    return("Giriş başarısız");
                }
            }
        }
        public int GetFeatureId(int productId, int featureId, string featureValue = "")
        {
            int ID = 0;

            using (TechContext context = new TechContext())
            {
                var featureID = (from i in context.FeatureDetails
                                 where i.FeatureID == featureId && i.ProductID == productId
                                 select i.ID);
                foreach (var i in featureID)
                {
                    ID += i;
                }

                return(ID);
            }
        }
        public int GetFeature(string featureName)
        {
            int ID = 0;

            using (TechContext context = new TechContext())
            {
                var featureID = (from i in context.Features
                                 where i.FeatureName == featureName
                                 select i.FeatureID);
                foreach (var i in featureID)
                {
                    ID += i;
                }

                return(ID);
            }
        }
Esempio n. 15
0
        public int GetProductID(string productName)
        {
            int ID = 0;

            using (TechContext context = new TechContext())
            {
                var productID = (from product in context.Products
                                 where product.ProductName == productName
                                 select product.ProductID);

                foreach (var i in productID)
                {
                    ID += i;
                }

                return(ID);
            }
        }
 public List <object> GetFeatureDetails()
 {
     using (TechContext context = new TechContext())
     {
         IQueryable <object> featureDetailsList = (from p in context.Products
                                                   join detail in context.FeatureDetails on p.ProductID equals detail.ProductID
                                                   join feature in context.Features on detail.FeatureID equals feature.FeatureID
                                                   select new
         {
             ProductName = p.ProductName,
             Feature = feature.FeatureName,
             Value = detail.FeatureValue,
         }
                                                   );
         List <object> featureList = new List <object>(featureDetailsList);
         return(featureList);
     }
 }
Esempio n. 17
0
        public int GetCategoryID(string categoryName)
        {
            int ID = 0;

            using (TechContext context = new TechContext())
            {
                var categoryID = (from category in context.Categories where category.CategoryName == categoryName select category.CategoryID
                                  );

                foreach (var i in categoryID)
                {
                    ID += i;
                }


                return(ID);
            }
        }
        public int GetUserId(string username)
        {
            int Id = 0;

            using (TechContext context = new TechContext())
            {
                var userId = (from i in context.Users
                              where i.UserName == username
                              select i.Id);

                foreach (var i in userId)
                {
                    Id += i;
                }

                return(Id);
            }
        }
Esempio n. 19
0
        public List <Product> SortProducts(int id, int index)
        {
            using (TechContext context = new TechContext())
            {
                if (index == (int)Sort.atoZ)
                {
                    var filtreProductList = (from product in context.Products
                                             where product.CategoryID == id
                                             orderby product.ProductName
                                             select product).ToList();
                    return(filtreProductList);
                }

                else if (index == (int)Sort.ztoA)
                {
                    var filtreProductList = (from product in context.Products
                                             where product.CategoryID == id
                                             orderby product.ProductName descending
                                             select product).ToList();
                    return(filtreProductList);
                }

                else if (index == (int)Sort.hightoLow)
                {
                    var filtreProductList = (from product in context.Products
                                             where product.CategoryID == id
                                             orderby product.AveragePrice descending
                                             select product).ToList();
                    return(filtreProductList);
                }

                else if (index == (int)Sort.lowtoHigh)
                {
                    var filtreProductList = (from product in context.Products
                                             where product.CategoryID == id
                                             orderby product.AveragePrice
                                             select product).ToList();
                    return(filtreProductList);
                }

                return(null);
            }
        }
Esempio n. 20
0
        public string ControlAdmin(string username, string email)
        {
            using (TechContext context = new TechContext())
            {
                var usernameControl = context.Admins.Where(p => p.Username == username).ToList();
                var emailControl    = context.Admins.Where(p => p.Email == email).ToList();
                if (usernameControl.Count > 0)
                {
                    return("0");
                }

                else if (emailControl.Count > 0)
                {
                    return("1");
                }

                return("-1");
            }
        }
Esempio n. 21
0
 public List <object> GetBrands()
 {
     using (TechContext context = new TechContext())
     {
         IQueryable <object> brandList = (from p in context.Products
                                          join brand in context.Brands on p.BrandID equals brand.BrandID
                                          select new { brand.BrandName, brand.BrandID } into x
                                          group x by new{ x.BrandID, x.BrandName } into b
                                          select  new
         {
             BrandID = b.Key.BrandID,
             Name = b.Key.BrandName,
             BrandCount = b.Select(x => x.BrandID).Count(),
             DisplayField = b.Key.BrandName + " (" + b.Select(x => x.BrandID).Count() + ")",
         }
                                          );
         List <object> list = new List <object>(brandList);
         return(list);
     }
 }
Esempio n. 22
0
        public List <object> CategoryCounter()
        {
            using (TechContext context = new TechContext())
            {
                IQueryable <object> categoryCount = from p in context.Products
                                                    join c in context.Categories
                                                    on p.CategoryID equals c.CategoryID
                                                    where (c.CategoryName != null)
                                                    select new { c.CategoryName, p.CategoryID, c.Icon } into x
                group x             by new { x.CategoryName, x.Icon, x.CategoryID } into g
                                    select new
                {
                    Name       = g.Key.CategoryName,
                    Count      = g.Select(x => x.CategoryID).Count(),
                    Icon       = g.Key.Icon,
                    CategoryID = g.Key.CategoryID,
                };

                List <object> list = new List <object>(categoryCount);
                return(list);
            }
        }
Esempio n. 23
0
        public List <object> GetProductDetails(string id)
        {
            using (TechContext context = new TechContext())
            {
                int productID = int.Parse(id);
                IQueryable <object> productDetails = (from i in context.Products
                                                      join j in context.FeatureDetails
                                                      on i.ProductID equals j.ProductID
                                                      where i.ProductID == productID
                                                      select new
                {
                    i.AveragePrice,
                    i.ProductImage_1,
                    i.ProductImage_2,
                    i.ProductImage_3,
                    i.ProductName,
                    j.Feature.FeatureName,
                    j.FeatureValue
                });

                List <object> list = new List <object>(productDetails);
                return(list);
            }
        }
Esempio n. 24
0
        public List <object> JoinProducts()
        {
            using (TechContext context = new TechContext())
            {
                IQueryable <object> productList = (from p in context.Products
                                                   join c in context.Categories on p.CategoryID equals c.CategoryID
                                                   join b in context.Brands on p.BrandID equals b.BrandID
                                                   where (p.ProductID != null)
                                                   select new
                {
                    Name = p.ProductName,
                    Category = c.CategoryName,
                    Brand = b.BrandName,
                    AveragePrice = p.AveragePrice,
                    ProductFeatures = p.ProductFeatures,
                    Image = p.ProductImage_1,
                    Image2 = p.ProductImage_2,
                    Image3 = p.ProductImage_3,
                });

                List <object> list = new List <object>(productList);
                return(list);
            }
        }