public async Task<ActionResult> Index() { if (User.Identity.GetUserId() != null) { var productRepository = new ProductRepository(); var HomeItems = new HomeViewModel(); int customerid = productRepository.GetCustomerID(User.Identity.GetUserId()); var tvr = await productRepository.GetTreeViewItems(); var id = productRepository.GetMostPopularItems(); var pb = productRepository.GetMostPopularBikes(customerid); var pc = productRepository.GetMostPopularClothing(customerid); var boyp = productRepository.BasedOnPurchase(customerid); var mpa = productRepository.MostPopularInArea(customerid); HomeItems.MostPopularInArea = mpa; HomeItems.BasedOnPurchase = boyp; HomeItems.PopularClothing = pc; HomeItems.PopularBikes = pb; HomeItems.Categories = tvr; HomeItems.modeldata = id; return View(HomeItems); } else { return RedirectToAction("Login", "Account"); } }
public ActionResult About(ProductViewModel pvm) { var productRepository = new ProductRepository(); int productid = pvm.ProductId; int customerid = productRepository.GetCustomerID(User.Identity.GetUserId()); int quantity = pvm.quantity; var idprod = productRepository.GetProductDetails(productid); pvm.LargePhoto = idprod.LargePhoto; pvm.listPrice = idprod.listPrice; pvm.Name = idprod.Name; pvm.color = idprod.color; pvm.Weight = idprod.Weight; pvm.size = idprod.size; pvm.description = idprod.description; var gpab = productRepository.GetPeopleAlsoBought(productid); pvm.PeopleAlsoBought = gpab; productRepository.InsertNewSaleItem(customerid, productid, quantity); TempData["alertmessage"] = "You have purchased "+ pvm.Name + " of quantity " + pvm.quantity ; //ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "You have purchased" + pvm.quantity + " items of" + pvm.Name, true); return View(pvm); }