コード例 #1
0
        public ActionResult Delete(TraSua trasua)
        {
            TraSua tra = DB.TraSuas.Find(trasua.mats);

            if (trasua != null)
            {
                DB.TraSuas.Remove(tra);
                DB.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult Details(TraSua trasua)
        {
            TraSua tra = DB.TraSuas.Find(trasua.mats);

            if (tra != null)
            {
                tra.mats    = trasua.mats;
                tra.tents   = trasua.tents;
                tra.huongvi = trasua.huongvi;
                tra.maloai  = trasua.maloai;
                tra.size    = trasua.size;
                tra.dongia  = trasua.dongia;
                tra.anhts   = trasua.anhts;
                tra.ghichu  = trasua.ghichu;
            }
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        // GET: ShoppingCart
        public ActionResult Add(int id)
        {
            ShoppingCart cart = (ShoppingCart)Session["cart"];

            if (cart == null)
            {
                cart = new ShoppingCart();
            }
            ShopModelData db     = new ShopModelData();
            TraSua        trasua = db.TraSuas.Find(id);

            if (trasua != null)
            {
                cart.InsertItem(trasua.mats, trasua.anhts, trasua.tents, (double)trasua.dongia);
            }

            Session["cart"] = cart;
            return(Redirect(Request.UrlReferrer.ToString()));
        }
コード例 #4
0
        public ActionResult Create(TraSua trasua, HttpPostedFileBase hinhanh)
        {
            if (hinhanh != null && hinhanh.ContentLength > 0)
            {
                var tenanh = Path.GetFileName(hinhanh.FileName);
                var link   = Path.Combine(Server.MapPath("~/Content/img/"), tenanh);

                trasua.anhts = tenanh;
                hinhanh.SaveAs(link);
            }
            if (ModelState.IsValid)
            {
                DB.TraSuas.Add(trasua);
                DB.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(trasua));
            }
        }
コード例 #5
0
        public ActionResult Edit(TraSua trasua, HttpPostedFileBase hinhanh)
        {
            TraSua tra = DB.TraSuas.Find(trasua.mats);

            if (tra != null)
            {
                if (hinhanh != null && hinhanh.ContentLength > 0)
                {
                    var tenanh = Path.GetFileName(hinhanh.FileName);
                    var link   = Path.Combine(Server.MapPath("~/Content/img/"), tenanh);

                    trasua.anhts = tenanh;
                    hinhanh.SaveAs(link);
                }
                else
                {
                }
                if (ModelState.IsValid)
                {
                    //tra.mats = trasua.mats;
                    tra.maloai  = trasua.maloai;
                    tra.tents   = trasua.tents;
                    tra.huongvi = trasua.huongvi;
                    tra.size    = trasua.size;
                    tra.dongia  = trasua.dongia;
                    tra.anhts   = trasua.anhts;
                    tra.ghichu  = trasua.ghichu;

                    DB.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(tra));
            }
        }