Esempio n. 1
0
        public List <DateTime> GetDateWeekly()
        {
            List <DateTime> dateList = new List <DateTime>();

            try
            {
                AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();
                ed1.Configuration.ProxyCreationEnabled = false;

                DateTime startOfWeek = DateTime.Today.AddDays(-1 * (int)(DateTime.Today.DayOfWeek));//this gives sunday as strt of the week day
                DateTime strtDate    = startOfWeek.Date;
                DateTime monday      = startOfWeek.Add(new TimeSpan(1, 0, 0, 0));
                DateTime mondayDate  = monday.Date;
                DateTime today       = DateTime.Today.Date;

                var difference = today - startOfWeek;

                if (difference.Days == 0)
                {
                    mondayDate = startOfWeek.Subtract(new TimeSpan(6, 0, 0, 0));
                    mondayDate = mondayDate.Date;
                }
                dateList = ed1.BrandFollowers.Where(x => x.Date >= mondayDate && x.Date <= today).Select(y => y.Date).Distinct().ToList();
                return(dateList);
            }catch (Exception)
            {
                return(dateList);
            }
        }
Esempio n. 2
0
        public List <Specification> GetAllSpecifications()
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            return(ed1.Specifications.Select(x => x).ToList());
        }
Esempio n. 3
0
        public List <int> GetFollowerCountonSpecificDate(DateTime dateTime, int brandId)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;


            DateTime startOfWeek = DateTime.Today.AddDays(-1 * (int)(DateTime.Today.DayOfWeek));//this gives sunday as strt of the week day


            DateTime strtDate   = startOfWeek.Date;
            DateTime monday     = startOfWeek.Add(new TimeSpan(1, 0, 0, 0));
            DateTime mondayDate = monday.Date;
            DateTime today      = dateTime.Date;
            var      difference = today - startOfWeek;

            if (difference.Days == 0)
            {
                strtDate = startOfWeek.Subtract(new TimeSpan(7, 0, 0, 0));
                strtDate = strtDate.Date;
            }

            List <int> folowerCount = ed1.BrandFollowers.Where(x => x.BrandId == brandId && (x.Date >= strtDate && x.Date <= today)).Select(y => y.FollowersCount).ToList();

            return(folowerCount);
        }
Esempio n. 4
0
        public void AddProductReviews(ProductReview review)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.ProductReviews.Add(review);
            ed1.SaveChanges();
        }
Esempio n. 5
0
        public void UpdateBrand(Brand b)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed.Entry(b).State = System.Data.EntityState.Modified;
            ed.SaveChanges();
        }
Esempio n. 6
0
        public void UpdateProduct(Product prod)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed.Entry(prod).State = System.Data.EntityState.Modified;
            ed.SaveChanges();
        }
Esempio n. 7
0
        public List <Product> SearchedProduct(string name)
        {
            List <Product> prodList    = new List <Product>();
            bool           searchfound = true;
            Product        p           = new Product();

            try
            {
                AdamDatabaseEntities2 ed = new AdamDatabaseEntities2();
                ed.Configuration.ProxyCreationEnabled = false;
                p = ed.Products.First(x => x.Title.Equals(name));
                prodList.Add(p);


                return(prodList);
            }
            catch (Exception)
            {
                searchfound = false;
            }
            if (!searchfound)
            {
                try
                {
                    AdamDatabaseEntities2 ed = new AdamDatabaseEntities2();
                    ed.Configuration.ProxyCreationEnabled = false;
                    prodList = ed.Products.Where(x => x.Title.Contains(name)).Select(x => x).Distinct().OrderByDescending(x => x.Rating).Take(4).ToList();
                }
                catch (Exception)
                { };
            }
            return(prodList);
        }
Esempio n. 8
0
        public void AddFeatureSentiment(FeatureSentiment fs)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            ed1.FeatureSentiments.Add(fs);
            ed1.SaveChanges();
        }
Esempio n. 9
0
        public void SaveReview(ProductReview pr)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            ed1.ProductReviews.Add(pr);
            ed1.SaveChanges();
        }
Esempio n. 10
0
        public dynamic GetAllReviewsAgainstProduct()
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            var products = ed1.Products.Include("ProductReviews").ToList();;

            return(products);
        }
Esempio n. 11
0
        //new
        public List <Brand> GetAllProductsAgainstBrand(int bId)
        {
            AdamDatabaseEntities2 ed = new AdamDatabaseEntities2();

            ed.Configuration.ProxyCreationEnabled = false;
            List <Brand> b = ed.Brands.Include("Products").Where(x => x.Id == bId).ToList();

            return(b);
        }
Esempio n. 12
0
        //new
        public int GetBrandId(string bName)
        {
            AdamDatabaseEntities2 ed = new AdamDatabaseEntities2();

            ed.Configuration.ProxyCreationEnabled = false;
            Brand brand = ed.Brands.First(x => x.Name.Equals(bName));

            return(brand.Id);
        }
Esempio n. 13
0
        //new
        public int GetCategoryId(string catName)
        {
            AdamDatabaseEntities2 ed = new AdamDatabaseEntities2();

            ed.Configuration.ProxyCreationEnabled = false;
            Category category = ed.Categories.First(x => x.Name.Equals(catName));

            return(category.Id);
        }
Esempio n. 14
0
        public List <Product> GetAllSpecificationsAgainstProduct(int pId)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            List <Product> productList = ed1.Products.Include("Product_Specification.Specification").Include("ProductReviews").Where(x => x.Id == pId).ToList();

            return(productList);
        }
Esempio n. 15
0
        public List <string> GetAllProductTitles()
        {
            AdamDatabaseEntities2 ed       = new AdamDatabaseEntities2();
            List <string>         nameList = new List <string>();

            ed.Configuration.ProxyCreationEnabled = false;
            nameList = ed.Products.Select(x => x.Title).ToList();
            return(nameList);
        }
Esempio n. 16
0
        public List <Brand> GetAllBrandOfMobiles()
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            List <Brand> brands = ed1.Brands.Where(y => y.CategoryId == 2).Select(x => x).ToList();

            return(brands);
        }
Esempio n. 17
0
        public List <Product> GetProductsToDisplay(string brand)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();
            Brand          b          = ed1.Brands.First(x => x.Name.ToLower().Equals(brand.ToLower()));
            int            brandId    = b.Id;
            List <Product> products   = ed1.Products.Where(x => x.BrandId == brandId).ToList();

            return(products);
        }
Esempio n. 18
0
        public Product GetSpecificProduct(int prodId)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            Product prod = ed.Products.First(x => x.Id == prodId);

            return(prod);
        }
Esempio n. 19
0
        public List <Product> GetTopRatedProducts()
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            List <Product> list = new List <Product>();

            return(list);
        }
Esempio n. 20
0
        public List <FeatureSentiment> GetRefinedFeaturesOfProduct(int pid)
        {
            AdamDatabaseEntities2 ed = new AdamDatabaseEntities2();

            ed.Configuration.ProxyCreationEnabled = false;
            List <FeatureSentiment> features = ed.FeatureSentiments.Where(x => x.PId.Equals(pid)).Select(y => y).ToList();

            return(features);
        }
Esempio n. 21
0
        public dynamic GetWeekLastDayTrend(int brandId)//not needed yet
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            DateTime startOfWeek  = DateTime.Today.AddDays(-1 * (int)(DateTime.Today.DayOfWeek));//this gives sunday as strt of the week day
            var      folowerCount = ed1.BrandFollowers.Where(x => x.BrandId == brandId && x.Date == startOfWeek.Date).Select(y => y.FollowersCount);

            return(folowerCount);
        }
Esempio n. 22
0
        //Add Product Details
        public int AddProductDetails(Product product, string type)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();;

            ed1.Configuration.ProxyCreationEnabled = false;
            product.CategoryId = GetCategoryIdToSaveProduct(product, type);
            product.BrandId    = GetBrandIdToSaveProduct(product, product.CategoryId);
            ed1.Products.Add(product);
            ed1.SaveChanges();
            return(product.Id);
        }
Esempio n. 23
0
        public void AddBrandFollower(BrandFollower follower)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            try
            {
                ed1.BrandFollowers.Add(follower);
                ed1.SaveChanges();
            }catch (Exception)
            {
            }
        }
Esempio n. 24
0
        //new
        public dynamic GetTopProductsAgainstBrandAndCategory(string catName, string bName)
        {
            AdamDatabaseEntities2 ed   = new AdamDatabaseEntities2();
            List <Product>        list = new List <Product>();

            ed.Configuration.ProxyCreationEnabled = false;
            int catId   = GetCategoryId(catName);
            int bId     = GetBrandId(bName);
            var strlist = ed.Products.Where(y => y.CategoryId.Equals(catId) && y.BrandId.Equals(bId)).Select(m => m).Distinct().OrderByDescending(x => x.Rating).Take(5).ToList();


            return(strlist);
        }
Esempio n. 25
0
        public List <Product> GetAllProducts()
        {
            //int bId = 0;
            //string bName = "";
            //Brand b = new Brand();
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            ed1.Configuration.ProxyCreationEnabled = false;
            List <Product> list = ed1.Products.ToList();


            return(list);
        }
Esempio n. 26
0
        public List <Product> CompareProduct(string prodName1, string prodName2)
        {
            bool prodCount = false;

            Product[]             arrList      = new Product[2];
            List <Product>        prodList     = new List <Product>();
            List <Product>        tempProdList = new List <Product>();
            AdamDatabaseEntities2 ed1          = new AdamDatabaseEntities2();

            ed.Configuration.ProxyCreationEnabled = false;
            try
            {
                tempProdList = ed.Products.Include("Product_Specification.Specification").Where(x => x.Title.Equals(prodName1) || x.Title.Equals(prodName2)).ToList();
                int count = 0;
                int i     = 0;
                foreach (Product p in tempProdList)
                {
                    prodCount = true;
                    if (count < 2)
                    {
                        if (tempProdList[i].Title.Equals(prodName1) && arrList[0] == null)
                        {
                            arrList[0] = tempProdList[i];
                            count++;
                        }
                        else if (tempProdList[i].Title.Equals(prodName2) && arrList[1] == null)
                        {
                            arrList[1] = tempProdList[i];
                            count++;
                        }
                    }
                    else
                    {
                        break;
                    }
                    i++;
                }
            }
            catch (Exception)
            {
                prodCount = false;
            }
            if (arrList[0] == null || arrList[1] == null)
            {
                return(prodList);
            }
            prodList.Add(arrList[0]);
            prodList.Add(arrList[1]);
            return(prodList);
        }
Esempio n. 27
0
        public bool CheckLoginDetails(string eamil, string password)
        {
            AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();

            try
            {
                Customer c = ed1.Customers.First(x => x.Email.Equals(eamil) && x.Password.Equals(password));
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 28
0
        public List <Brand> GetAllBrands()
        {
            List <Brand> b = new List <Brand>();

            try
            {
                AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();
                ed1.Configuration.ProxyCreationEnabled = false;
                b = ed1.Brands.ToList();
                return(b);
            }
            catch (Exception)
            {
                return(b);
            }
        }
Esempio n. 29
0
        public List <Customer_AreaOfInterest> GetAllCustomersInterest()
        {
            List <Customer_AreaOfInterest> cusAreaInterest = new List <Customer_AreaOfInterest>();

            try
            {
                AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2();
                ed1.Configuration.ProxyCreationEnabled = false;
                cusAreaInterest = ed.Customer_AreaOfInterest.ToList();
                return(cusAreaInterest);
            }
            catch (Exception)
            {
                return(cusAreaInterest);
            }
        }
Esempio n. 30
0
        public List <Product> GetRelatedProducts(string prodName, int prodId)
        {
            string[]       token   = prodName.Split(' ');
            string         series  = token[1];
            List <Product> product = new List <Product>();

            try
            {
                AdamDatabaseEntities2 ed = new AdamDatabaseEntities2();
                ed.Configuration.ProxyCreationEnabled = false;

                // var temp= ed.Products.Where(x => x.Title.Contains(series)).Select(x=>x.Title).Distinct()).OrderByDescending(x => x.Rating).Take(5).ToList();
                product = ed.Products.Where(x => x.Title.Contains(series) && x.Id != prodId && (!(x.Title.Contains(prodName)))).Select(m => m).Distinct().OrderByDescending(x => x.Rating).Take(5).ToList();
            }
            catch (Exception)

            { };
            return(product);
        }