Exemplo n.º 1
0
        private void Edit(int id, string name)
        {
            var result = roleBll.GetRoleById(id).First();

            if (result == null)
            {
                logger.Error("Role does not exist");
                throw new HttpException(412, "Role does not exist");
            }
            roleBll.UpdateRole(id, name);
            logger.Trace("Success");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 返回编辑页部分视图
        /// </summary>
        /// <param name="id">角色ID</param>
        /// <returns>部分视图</returns>
        public ActionResult RoleDetail(int id = 0)
        {
            RoleFormViewModel roleForm = new RoleFormViewModel();

            if (id != 0)
            {
                RoleBll bll  = new RoleBll();
                Role    role = bll.GetRoleById(id);
                if (role != null)
                {
                    roleForm.RoleName    = role.RoleName;
                    roleForm.Id          = role.Id;
                    roleForm.Description = role.Description;
                    roleForm.Code        = role.Code;
                }
                else
                {
                    return(PartialView("CreatAndEdit", roleForm));
                }
            }
            return(PartialView("CreatAndEdit", roleForm));
        }