public ActionResult Brands(int id, ShopModel m) //Sadece ProductsManager ile yapıldı { if (BrandsFilter == null) { BrandsFilter = new List <int>(); } //if (m.BrandsFilter == null) //{ // m.BrandsFilter = new List<Brands>(); //} ProductsManager pm = new ProductsManager(); BrandsManager bm = new BrandsManager(); BrandsFilter.Add(id); //m.marka.Add(bm.Single(id).BrandName); //m.BrandsFilter.Add(bm.Single(id)); //m.BrandsFilter = bm.GetAll().Where(x => x.BrandID == id).ToList(); //Session["BrandsFilter"] = BrandsFilter; //foreach (var item in m.BrandsFilter) //{ // m.BrandsFilter.Add(bm.Single(id)); //} m.plist = pm.GetAll().Where(x => BrandsFilter.Contains(x.BrandID)).ToList(); Session["Products"] = m.plist; return(RedirectToAction("Shop", "Shop", m)); }
static void Main(string[] args) { ProductsManager productsManager = new ProductsManager(new InMemoryProductsDal()); ProductsManager productsManagerSql = new ProductsManager(new SqlProductsDal()); Product product2 = new Product { BrandId = 1, ColorId = 6, Price = 127, ProductId = 7, ProductTypeId = 1, SexId = 1 }; productsManagerSql.Add(product2); foreach (var product in productsManager.GetAll()) { string brandName = productsManager.GetProductBrand(product.BrandId); string colorName = productsManager.GetProductColor(product.ColorId); string sexName = productsManager.GetProductSex(product.SexId); string productType = productsManager.GetProductType(product.ProductTypeId); Console.WriteLine( "{0}: Brand: {1} --- Color: {2} --- Sex:{3} --- Price:{4} --- Type: {5}" , product.ProductId, brandName, colorName, sexName, product.Price, productType ); } Console.WriteLine("4'th products color: " + productsManager.GetProductColor(productsManager.GetById(4).ColorId)); Product product1 = productsManager.GetById(6); Console.WriteLine("6'th products brand: " + productsManager.GetProductBrand(product1.BrandId)); }
public ActionResult Hl(ShopModel m) { ProductsManager pm = new ProductsManager(); m.plist = pm.GetAll().OrderByDescending(x => x.UnitPrice).ToList(); Session["Products"] = m.plist; return(RedirectToAction("Shop", "Shop", m)); }
public PartialViewResult ProductPartial(string sortOrder, string searchString, int?page, bool forOwner, string userId) { if (searchString != null) { page = 1; } IEnumerable <Product> pr; if (forOwner) { if (userId != _userProfileManager.GetUserProfileId(User)) { throw new Exception("User ids doesn't match"); } pr = _userProfileManager.GetAllProductByOwner(User); } else { pr = _productsManager.GetAll(); } var products = ConvertToViewModel(_userProfileManager.GetUserProfileId(User), pr); if (!string.IsNullOrEmpty(searchString)) { searchString = searchString.Trim().ToLower(); products = products.Where(s => s.Description.ToLower().Contains(searchString)); } switch (sortOrder) { case "price_desc": products = products.OrderByDescending(p => p.Price); break; case "date_asc": products = products.OrderBy(p => p.CreatedOn); break; case "date_desc": products = products.OrderByDescending(p => p.CreatedOn); break; default: products = products.OrderBy(p => p.Price); break; } return(PartialView(PaginatedList <ProductViewModel> .Create(products.AsQueryable(), page ?? 1, ITEMS_ON_PAGE))); }
// GET: Home public ActionResult Index() { CategoriesManager cm = new CategoriesManager(); ProductsManager pm = new ProductsManager(); BrandsManager bm = new BrandsManager(); ColorManager colm = new ColorManager(); SizeManager sm = new SizeManager(); ProductCategoriesManager pcm = new ProductCategoriesManager(); ProductColorsManager pcolm = new ProductColorsManager(); ProductSizesManager pszm = new ProductSizesManager(); BasketManager basm = new BasketManager(); BasketDetailManager bdm = new BasketDetailManager(); BasketTempManager btm = new BasketTempManager(); ParamManager parm = new ParamManager(); Session["Categories"] = cm.GetAll(); Session["Products"] = pm.GetAll(); Session["Brands"] = bm.GetAll(); Session["Colors"] = colm.GetAll(); Session["Sizes"] = sm.GetAll(); Session["ProductCategories"] = pcm.GetAll(); Session["ProductColorsManager"] = pcolm.GetAll(); Session["ProductSizesManager"] = pszm.GetAll(); Session["Basket"] = basm.GetAll(); Session["BasketDetail"] = bdm.GetAll(); Session["BasketTemp"] = btm.GetAll(); Session["Param"] = parm.GetAll(); baskettlist = btm.GetAll();; ViewBag.Login = "******"; ViewBag.Logout = "Logout"; return(View()); }
/// <summary> /// Goes to products list page /// </summary> /// <returns></returns> public ActionResult Index() { return(View(Mapper.Map <List <Product>, List <ProductVM> >(manager.GetAll()))); }