コード例 #1
0
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            string id = controllerContext.HttpContext.Request.Form.Get("item.Id");
            string groupId = controllerContext.HttpContext.Request.Form.Get("item.GroupId");
            string role = controllerContext.HttpContext.Request.Form.Get("item.Role");
            string mail = controllerContext.HttpContext.Request.Form.Get("item.Mail");
            string name = controllerContext.HttpContext.Request.Form.Get("item.Name");
            Roles userRole = (Roles)Enum.Parse(typeof(FICTFeed.Bussines.AdditionalData.Roles), role);

            var model = new UserEditViewModel(name, mail, userRole);
            model.Id = Guid.Parse(id);
            model.GroupId = Guid.Parse(groupId);
            return model;
        }
コード例 #2
0
        public ActionResult EditUserRole(UserEditViewModel model)
        {
            var user = userManager.GetById(model.Id.ToString());
            if (user == null)
                return View();

            user.Role = model.Role;
            user.GroupId = model.GroupId;

            userManager.Update(user);

            return RedirectToRoute("GetUsers");
        }