//
 // GET: /ManagerUser/Details/5
 public ActionResult Details(int id = 0)
 {
     UserProfile userprofile = db.UserProfiles.Find(id);
     if (userprofile == null)
     {
         return HttpNotFound();
     }
     UserRole userRole= new UserRole()
     {
         role = userprofile.webpages_Roles,
         userName = userprofile.UserName,
         userid = userprofile.UserId
     };
     return View(userRole);
 }
 //
 // GET: /ManagerUser/Edit/5
 public ActionResult Edit(int id = 0)
 {
     UserProfile userprofile = db.UserProfiles.Find(id);
     if (userprofile == null)
     {
         return HttpNotFound();
     }
     UserRole userRole = new UserRole()
     {
         role = userprofile.webpages_Roles,
         userName = userprofile.UserName,
         userid = userprofile.UserId
     };
     var listItems = new List<ListItem>();
     foreach (var item in db.webpages_Roles)
     {
         listItems.Add(new ListItem { Text = item.RoleName, Value = item.RoleId.ToString() });
     }
     ViewBag.itemList = listItems;
     return View(userRole);
 }
        public ActionResult Edit(UserRole userprofile,string role)
        {
            try
            {
                UserProfile userprofile1 = new UserProfile();
                userprofile1.UserId = userprofile.userid;
                userprofile1.UserName = userprofile.userName;
                List<webpages_Roles> collect = new List<webpages_Roles>();
                collect.Add(db.webpages_Roles.Find(int.Parse(role)));
                userprofile1.webpages_Roles = collect as ICollection<webpages_Roles>;
                List<ModelState> asdf = ModelState.Values.ToList();

                db.Entry(userprofile1).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return View(userprofile);
            }
        }