// GET: Seller/Acount public ActionResult Dashboard() { if (Session["userID"] != null) { // kiem tra co phai nhan viên cửa hàng if (Convert.ToInt32(Session["roleID"]) != 4) { return(View("Login")); } else if (Convert.ToInt32(Session["roleID"]) == 4) { Session["userID"] = 2; } ProductsClient CC = new ProductsClient(); int Storeid = CC.Storeid(Convert.ToInt32(Session["userID"])); //kiem tra role nhan vien thi dang nhap trang shop cua admin //if (Convert.ToInt32(Session["role"]) == 4) //{ // Storeid = CC.Storeid(Convert.ToInt32(Session["AdminShop"])); //} ViewBag.listProducts = CC.findAll(Storeid); return(View()); } else { return(View("Login")); } }
// GET: Seller/Products public ActionResult Index() { ViewBag.MaintypeID = new SelectList(db.Main_Type, "ID", "Name"); ViewBag.TypeID = new SelectList(db.Product_Type, "TypeID", "Name"); ProductsClient CC = new ProductsClient(); int Storeid = CC.Storeid(Convert.ToInt32(Session["userID"])); ViewBag.listProducts = CC.findAll(Storeid); return(View()); }
//public PartialViewResult Getpaging(int? page) //{ // ProductClient CC = new ProductClient(); // int Storeid = CC.Storeid(Convert.ToInt32(Session["userID"])); // int pageNumber = (page ?? 1); // ViewBag.listProducts = CC.findAll(Storeid).ToPagedList(pageNumber, pageSize); // //return View("Index"); // return PartialView("~/Areas/Seller/Views/Products/Search.cshtml"); //} //public ActionResult Paginate(int pageNumber) //{ // ProductsClient CC = new ProductsClient(); // int Storeid = CC.Storeid(Convert.ToInt32(Session["userID"])); // ViewBag.listProducts = CC.findAll(Storeid).ToPagedList(pageNumber, PageSize); // return PartialView("~/Areas/Seller/Views/Products/Search.cshtml"); //} public ActionResult Search(string Name, int TypeID, int MinAmount, int MaxAmount) { ProductsClient CC = new ProductsClient(); int Storeid = CC.Storeid(Convert.ToInt32(Session["userID"])); Find filter = new Find(); filter.StoreID = Storeid; filter.Name = Name; filter.TypeID = TypeID; filter.QualityMin = MinAmount; filter.QualityMax = MaxAmount; ViewBag.listProducts = CC.filter(filter); return(PartialView("~/Areas/Seller/Views/Products/Search.cshtml")); //} }
public ActionResult Create(ProductViewModel cvm, HttpPostedFileBase file) { //HttpPostedFileBase file = Request.Files[0]; if (ModelState.IsValid) { if (file != null) { string ImageName = Path.GetFileName(file.FileName); string physicalPath = Server.MapPath("~/Product_Images/" + ImageName); // save image in folder file.SaveAs(physicalPath); cvm.product.Pictures = ImageName; } ProductsClient CC = new ProductsClient(); int Storeid = CC.Storeid(Convert.ToInt32(Session["userID"])); cvm.product.Store_ID = Storeid; CC.Create(cvm.product); } return(RedirectToAction("Index")); }
public ActionResult Edit(ProductViewModel CVM, HttpPostedFileBase file) { if (ModelState.IsValid) { ProductsClient CC = new ProductsClient(); if (file == null) { CVM.product.Pictures = CC.find(CVM.product.Product_ID).Pictures; } else { string ImageName = Path.GetFileName(file.FileName); string physicalPath = Server.MapPath("~/Product_Images/" + ImageName); // save image in folder file.SaveAs(physicalPath); CVM.product.Pictures = ImageName; } int Storeid = CC.Storeid(Convert.ToInt32(Session["userID"])); CVM.product.Store_ID = Storeid; CC.Edit(CVM.product); } return(RedirectToAction("Index")); }