예제 #1
0
        /// <summary>
        /// 增删减一个角色
        /// </summary>
        /// <param name="updateType">更新类型,1-新增,2-修改,3-删除</param>
        /// <param name="id">角色的ID</param>
        /// <returns></returns>
        public ActionResult UpdateRole(string updateType, string id)
        {
            Roles data = new Roles();

            if (string.IsNullOrEmpty(updateType))
            {
                updateType = "1";
            }

            switch (updateType)
            {
            case "1":
                break;

            case "2":
                UserDbContext uc1 = new UserDbContext("ConnStr1");
                data = uc1.GetRoleByID(id);
                break;

            case "3":
                UserDbContext uc2 = new UserDbContext("ConnStr1");
                data = uc2.GetRoleByID(id);
                break;

            default:
                throw new Exception("更新类型出错。");
            }

            if (data == null)
            {
                data = new Roles();
            }

            return(View(data));
        }