Ejemplo n.º 1
0
        /// <summary>
        /// 添加编辑角色
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public void AddEdit(OrgAddEditDto dto)
        {
            dto.OrgName = dto.OrgName.Trim();
            SysOrg org = null;

            if (dto.OrgId.HasValue)
            {
                org                = _repository.FirstOrDefault(o => o.OrgId == dto.OrgId.Value);
                org.ModifyDate     = DateTime.Now;
                org.ModifyUserId   = _userManager.UserId;
                org.ModifyUserName = _userManager.UserName;
            }
            else
            {
                org = new SysOrg()
                {
                    CreateDate     = DateTime.Now,
                    CreateUserId   = _userManager.UserId,
                    CreateUserName = _userManager.UserName,
                    IsLeaf         = false,
                    IsDeleted      = false
                };
            }
            org.OrgName       = dto.OrgName;
            org.ParentOrgId   = dto.ParentOrgId;
            org.ParentOrgName = dto.ParentOrgId > 0 ? dto.ParentOrgName : "";
            org.Status        = dto.Status;
            org.SortNo        = dto.SortNo ?? 0;
            if (org.ParentOrgId > 0)
            {
                if (dbClint.Queryable <SysOrg>().Where(o => o.OrgName == dto.OrgName && o.ParentOrgId == dto.ParentOrgId && o.OrgId != dto.OrgId && o.IsDeleted == false).Any())
                {
                    throw Oops.Oh("同部门下的子部门不能重复!");
                }
            }
            if (dto.OrgId.HasValue)
            {
                dbClint.Updateable(org).ExecuteCommand();
            }
            else
            {
                dbClint.Insertable(org).ExecuteCommand();
            }
        }
Ejemplo n.º 2
0
 public bool OrgAddEdit([FromBody] OrgAddEditDto dto)
 {
     _sysOrgService.AddEdit(dto);
     return(true);
 }