public ActionResult Create(string roleId, string userId) { if (ModelState.IsValid) { var user = db.AspNetUsers.Find(userId); var role = db.AspNetRoles.Find(roleId); role.AspNetUsers.Add(user); db.Entry(role).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "AspNetRole")); } return(RedirectToAction("Create")); }
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(Product model, HttpPostedFileBase picture) { ValidateProduct(model); if (ModelState.IsValid) { using (var scope = new TransactionScope()) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); if (picture != null) { var path = Server.MapPath(Picture_PATH); picture.SaveAs(path + model.id); } scope.Complete(); return(RedirectToAction("Index")); } } ViewBag.cate_id = new SelectList(db.Categories, "id", "name", model.cate_id); return(View(model)); }