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); } }
public List <Specification> GetAllSpecifications() { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed1.Configuration.ProxyCreationEnabled = false; return(ed1.Specifications.Select(x => x).ToList()); }
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); }
public void AddProductReviews(ProductReview review) { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed1.ProductReviews.Add(review); ed1.SaveChanges(); }
public void UpdateBrand(Brand b) { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed.Entry(b).State = System.Data.EntityState.Modified; ed.SaveChanges(); }
public void UpdateProduct(Product prod) { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed.Entry(prod).State = System.Data.EntityState.Modified; ed.SaveChanges(); }
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); }
public void AddFeatureSentiment(FeatureSentiment fs) { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed1.Configuration.ProxyCreationEnabled = false; ed1.FeatureSentiments.Add(fs); ed1.SaveChanges(); }
public void SaveReview(ProductReview pr) { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed1.Configuration.ProxyCreationEnabled = false; ed1.ProductReviews.Add(pr); ed1.SaveChanges(); }
public dynamic GetAllReviewsAgainstProduct() { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed1.Configuration.ProxyCreationEnabled = false; var products = ed1.Products.Include("ProductReviews").ToList();; return(products); }
//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); }
//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); }
//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); }
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); }
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); }
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); }
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); }
public Product GetSpecificProduct(int prodId) { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed1.Configuration.ProxyCreationEnabled = false; Product prod = ed.Products.First(x => x.Id == prodId); return(prod); }
public List <Product> GetTopRatedProducts() { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); ed1.Configuration.ProxyCreationEnabled = false; List <Product> list = new List <Product>(); return(list); }
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); }
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); }
//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); }
public void AddBrandFollower(BrandFollower follower) { AdamDatabaseEntities2 ed1 = new AdamDatabaseEntities2(); try { ed1.BrandFollowers.Add(follower); ed1.SaveChanges(); }catch (Exception) { } }
//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); }
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); }
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); }
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); } }
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); } }
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); } }
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); }