public void TestEditPost()
        {
            var db    = new CsK23T2aEntities1();
            var model = new tablePRODUCTofYourCart
            {
                idSP  = db.tablePRODUCTofYourCarts.AsNoTracking().First().idSP,
                tenSP = "Vay Sieu Nhan"
            };
            var controller = new Admin_tablePRODUCTofYourCartsController();

            using (var scope = new TransactionScope())
            {
                //var result = controller.Create(model);
                //var view = result as ViewResult;


                //controller = new Admin_tablePRODUCTofYourCartsController();
                //result = controller.Edit(model);

                //var redirect = result as RedirectToRouteResult;

                //Assert.IsNotNull(redirect);
                //Assert.AreEqual("Index", redirect.RouteValues["action"]);

                //var item = db.tablePRODUCTofYourCarts.Find(model.idSP);

                //Assert.IsNotNull(item);
                //Assert.AreEqual(model.tenSP, item.tenSP);
            }
        }
예제 #2
0
        public ActionResult Edit(tablePRODUCTofYourCart model)
        {
            if (ModelState.IsValid)
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                TempData["StatusMessage"] = "Edit successfully";

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public void TestCreatePost()
        {
            var db    = new CsK23T2aEntities1();
            var model = new tablePRODUCTofYourCart
            {
                tenSP  = "Vay Sieu Nhan",
                ghichu = "1"
            };
            var controller = new Admin_tablePRODUCTofYourCartsController();

            using (var scope = new TransactionScope())
            {
            }
        }
예제 #4
0
        public ActionResult Create(tablePRODUCTofYourCart model)
        {
            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    // add model to database
                    db.tablePRODUCTofYourCarts.Add(model);
                    db.SaveChanges();
                    TempData["StatusMessage"] = "Create successfully";
                    // save file to App_Data
                    var path = Server.MapPath("~/App_Data");
                    path = System.IO.Path.Combine(path, model.idSP.ToString());
                    Request.Files["Image"].SaveAs(path);
                    // accept all and persistence
                    scope.Complete();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(model));
        }