Beispiel #1
0
        public ActionResult Create(string roleId, string userId)
        {
            var role = db.AspNetRoles.Find(roleId);
            var user = db.AspNetUsers.Find(userId);

            role.AspNetUsers.Add(user);
            db.Entry(role).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index", "AspNetRoles"));
        }
        public ActionResult Edit(SANPHAM model, HttpPostedFileBase picture)
        {
            ValidateProduct(model);
            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    db.Entry(model).State = EntityState.Modified;
                    db.SaveChanges();
                    if (picture != null)
                    {
                        // store picture
                        var path = Server.MapPath(PICTURE_PATH);
                        picture.SaveAs(path + model.MASP);
                    }



                    scope.Complete();
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.MAKM   = new SelectList(db.KHUYENMAIs, "MAKHUYENMAI", "TENKHUYENMAI", model.MAKM);
            ViewBag.LOAISP = new SelectList(db.LOAISANPHAMs, "MALOAISP", "TENLOAISP", model.LOAISP);
            ViewBag.MANCC  = new SelectList(db.NHACUNGCAPs, "MANHACUNGCAP", "TENNHACUNGCAP", model.MANCC);
            return(View(model));
        }
 public ActionResult Edit([Bind(Include = "Id,Name")] AspNetRole aspNetRole)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aspNetRole).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aspNetRole));
 }
 public ActionResult Edit([Bind(Include = "ID,MASANPHAM,MATAIKHOAN,HOTEN,NOIDUNG,THOIGIANDANG,SOSAODANHGIA")] REVIEWRATING rEVIEWRATING)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rEVIEWRATING).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.MASANPHAM = new SelectList(db.SANPHAMs, "MASP", "TENSP", rEVIEWRATING.MASANPHAM);
     return View(rEVIEWRATING);
 }