Example #1
0
        public ActionResult RoleTypeInfo(RoleTypeDTO dto)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(dto.Id))
                {
                    string result = RoleTypeSrv.InsertRoleType(dto);
                    if (!string.IsNullOrEmpty(result) && result != "-2")
                    {
                        result = "1";
                    }
                    return(Content(result, "text/plain"));
                }
                else
                {
                    RoleTypeSrv.UpdateRoleType(dto);
                    return(Content("1"));
                }
            }

            //获取ErrorMessage
            string errorMsg = ModelState.Values.First(x => x.Errors.Count > 0).Errors[0].ErrorMessage;

            return(Content(errorMsg, "text/plain"));
        }
Example #2
0
        public RoleTypeDTO ToRoleTypeDTO(RoleType item)
        {
            RoleTypeDTO result = new RoleTypeDTO();

            result.ID           = item.ID;
            result.Name         = item.Name;
            result.IsSuperAdmin = item.IsSuperAdmin == true;
            return(result);
        }
Example #3
0
        /// <summary>
        /// 更新角色分类。
        /// </summary>
        /// <param name="dto">待更新角色分类的信息。</param>
        public static void UpdateRoleType(RoleTypeDTO dto)
        {
            Db.SessionFactory.EvictQueries("RoleType");

            RoleType rt = Db.Session.Load(typeof(RoleType), dto.Id) as RoleType;

            rt.Name    = dto.Name;
            rt.Remark  = dto.Remark;
            rt.OrderId = dto.OrderId;

            Db.TransUpdate(rt);
        }
Example #4
0
        /// <summary>
        /// 编辑Roletype
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ActionResult EditRoleType(string Id)
        {
            RoleType    roletype = CommonSrv.LoadObjectById(typeof(RoleType), Id) as RoleType;
            RoleTypeDTO dto      = new RoleTypeDTO();

            dto.Id               = roletype.Id;
            dto.Name             = roletype.Name;
            dto.OrderId          = roletype.OrderId;
            dto.Remark           = roletype.Remark;
            dto.ParentRoleTypeId = roletype.ParentRoleType == null ? "" : roletype.ParentRoleType.Id;
            return(View("RoleTypeInfo", dto));
        }
Example #5
0
        /// <summary>
        /// 获取Roletype 详情,返回json 数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public JsonResult RoleTypeInfo(string Id)
        {
            JsonResult jresult = new JsonResult();

            jresult.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            try
            {
                RoleType    domain = CommonSrv.LoadObjectById(typeof(RoleType), Id) as RoleType;
                RoleTypeDTO dto    = new RoleTypeDTO();
                dto.Id       = domain.Id;
                dto.Name     = domain.Name;
                dto.OrderId  = domain.OrderId;
                dto.Remark   = domain.Remark;
                jresult.Data = dto;
            }
            catch
            {
                //TODO js 异常判断
                jresult.Data = "[{result:-1}]";
            }
            return(jresult);
        }
Example #6
0
        /// <summary>
        /// 新增角色分类。
        /// </summary>
        /// <param name="dto">待新增角色分类的信息。</param>
        /// <returns>新角色分类的Id。</returns>
        public static string InsertRoleType(RoleTypeDTO dto)
        {
            Db.SessionFactory.EvictQueries("RoleType");

            RoleType rt = new RoleType();

            rt.Id      = IdGen.GetNextId(typeof(RoleType));
            rt.Name    = dto.Name;
            rt.Remark  = dto.Remark;
            rt.OrderId = dto.OrderId;

            RoleType prt = null;

            if (dto.ParentRoleTypeId != null && dto.ParentRoleTypeId.Length > 0)
            {
                prt = Db.Session.Load(typeof(RoleType), dto.ParentRoleTypeId) as RoleType;
                prt.AddSubRoleType(rt);
            }

            Db.TransInsert(rt);

            return(rt.Id);
        }