public ActionResult Edit_Users(UserProfileR userProfileR, string role)
        {
            if (!redirectNonAdmin())
            {
                return RedirectToAction("Index", "Main");
            }

            if (ModelState.IsValid)
            {
                //db.Entry(predmetdb).State = EntityState.Modified;

                UserProfile userProfileEdit = db.UserProfile.First(u => u.UserId == userProfileR.UserId);
                userProfileEdit.FIOShort = userProfileR.FIOShort;
                userProfileEdit.UserName = userProfileR.UserName;
                db.SubmitChanges();

                webpages_UsersInRoles usersInRolesNew = new webpages_UsersInRoles();
                webpages_UsersInRoles usersInRolesEdit = db.webpages_UsersInRoles.First(u => u.UserId == userProfileR.UserId);
                usersInRolesNew.RoleId = Convert.ToInt32(role);
                usersInRolesNew.UserId = userProfileR.UserId;

                db.webpages_UsersInRoles.DeleteOnSubmit(usersInRolesEdit);
                db.SubmitChanges();

                db.webpages_UsersInRoles.InsertOnSubmit(usersInRolesNew);
                db.SubmitChanges();

                return RedirectToAction("Index_Users");
            }
            return View(userProfileR);
        }
        public ActionResult Edit_Users(int id = 0)
        {
            if (!redirectNonAdmin())
            {
                return RedirectToAction("Index", "Main");
            }

            ViewBag.dbRoles = db.webpages_Roles;

            UserProfile userProfile = db.UserProfile.First(u => u.UserId == id);
            webpages_UsersInRoles usersInRoles = db.webpages_UsersInRoles.First(u => u.UserId == id);
            webpages_Roles roles = db.webpages_Roles.First(u => u.RoleId == usersInRoles.RoleId);
            if (userProfile == null)
            {
                return HttpNotFound();
            }
            UserProfileR userProfileR = new UserProfileR();
            userProfileR.usersInRoles = new Models.webpages_UsersInRoles();
            userProfileR.FIOShort = userProfile.FIOShort;
            userProfileR.UserId = userProfile.UserId;
            userProfileR.UserName = userProfile.UserName;
            userProfileR.roles = new Models.webpages_Roles();

            userProfileR.usersInRoles.RoleId = usersInRoles.RoleId;
            userProfileR.usersInRoles.UserId = usersInRoles.UserId;
            userProfileR.roles.RoleId = roles.RoleId;
            userProfileR.roles.RoleName = roles.RoleName;
            ViewBag.RoleId = roles.RoleId;
            return View(userProfileR);
        }