public GioHangViewModels(int ID, string IDLoaiSanPham)
 {
     this.ID            = ID;
     this.IDLoaiSanPham = IDLoaiSanPham;
     if (IDLoaiSanPham == "Phone")
     {
         Phone phone = PhoneBLL.GetSinglePhone(ID, IDLoaiSanPham);
         TenSanPham = phone.TenSanPham;
         HinhAnh    = phone.HinhAnhSanPham;
         DonGia     = phone.GiaSanPham;
     }
     else if (IDLoaiSanPham == "Laptop")
     {
         Laptop laptop = LaptopBLL.GetSingleLaptop(ID, IDLoaiSanPham);
         TenSanPham = laptop.TenSanPham;
         HinhAnh    = laptop.HinhAnhSanPham;
         DonGia     = laptop.GiaSanPham;
     }
     else
     {
         Tablet tablet = TabletBLL.GetSingleTablet(ID, IDLoaiSanPham);
         TenSanPham = tablet.TenSanPham;
         HinhAnh    = tablet.HinhAnhSanPham;
         DonGia     = tablet.GiaSanPham;
     }
 }
 public ActionResult Index()
 {
     ViewBag.Laptops = LaptopBLL.GetLaptops();
     ViewBag.Phones  = PhoneBLL.GetPhones();
     ViewBag.Tablets = TabletBLL.GetTablets();
     return(View());
 }
        public ViewResult ChiTietTablet(int ID)
        {
            var tablet = TabletBLL.GetSingleTablet(ID);

            if (tablet == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(tablet));
        }
        public ActionResult Create(Tablet tablet, HttpPostedFileBase fileUpload)
        {
            var fileName = Path.GetFileName(fileUpload.FileName);
            var path     = Path.Combine(Server.MapPath("~/Images"), fileName);

            if (System.IO.File.Exists(path))
            {
                ViewBag.ThongBao = "Hình ảnh đã tồn tại";
            }
            else
            {
                fileUpload.SaveAs(path);
            }
            tablet.HinhAnhSanPham = fileUpload.FileName;
            TabletBLL.InsertIntoTablet(tablet);
            return(RedirectToAction("Tablet"));
        }
        public ActionResult SearchResults(FormCollection data)
        {
            var laptops = LaptopBLL.Search(data["search"].ToString());
            var phones  = PhoneBLL.Search(data["search"].ToString());
            var tablets = TabletBLL.Search(data["search"].ToString());

            if (laptops.Count == 0 && phones.Count == 0 & tablets.Count == 0)
            {
                ViewBag.Message = "Không tìm thấy sản phẩm nào";
            }
            var products = new ProductViewModels();

            products.Laptops = laptops;
            products.Phones  = phones;
            products.Tablets = tablets;
            return(View(products));
        }
 public JsonResult Delete(int ID)
 {
     TabletBLL.DeleteIntoTablet(ID);
     return(Json(ID, JsonRequestBehavior.AllowGet));
 }
 public ActionResult Details(int ID)
 {
     return(View(TabletBLL.GetSingleTablet(ID)));
 }
 public ActionResult Edit(Tablet tablet)
 {
     TabletBLL.UpdateIntoTablet(tablet);
     return(RedirectToAction("Tablet"));
 }
 // GET: Admin/AdminTablet
 public ActionResult Tablet()
 {
     return(View(TabletBLL.GetAll()));
 }