Exemple #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <JsonResponse> Remove(EntityRequest input)
        {
            input.InitModifyRequest();
            var resJson = await _applicationEnginee.TryTransactionAsync(async() =>
            {
                await _organizationElementAppService.RemoveAsync(input);
            });

            return(resJson);
        }
Exemple #2
0
        /// <summary>
        /// 删除模块
        /// </summary>
        /// <param name="entityRequest"></param>
        /// <returns></returns>
        public async Task <JsonResponse> RemoveModule(EntityRequest entityRequest)
        {
            var elementDtos   = await _moduleElementAppService.GetElementByModuleIds(entityRequest.Ids);;
            var elementIds    = elementDtos.Select(r => r.Id).ToList();
            var orgElementIds = await _organizationElementAppService.GetIdsByModuleElementIdsAsync(elementIds);

            var roleElementIds = await _roleElementAppService.GetIdsByModuleElementIdsAsync(elementIds);

            var empElementIds = await _employeeElementAppService.GetIdsByModuleElementIdsAsync(elementIds);

            var resJson = await _applicationEnginee.TryTransactionAsync(async() =>
            {
                await _moduleAppService.RemoveAsync(entityRequest);
                await _moduleElementAppService.RemoveAsync(new EntityRequest()
                {
                    Ids            = elementIds,
                    CreateDate     = DateTime.Now,
                    CreateUserId   = entityRequest.CreateUserId,
                    CreateUserName = entityRequest.CreateUserName
                });
                await _organizationElementAppService.RemoveAsync(new EntityRequest()
                {
                    Ids            = orgElementIds,
                    CreateDate     = DateTime.Now,
                    CreateUserId   = entityRequest.CreateUserId,
                    CreateUserName = entityRequest.CreateUserName
                });
                await _roleElementAppService.RemoveAsync(new EntityRequest()
                {
                    Ids            = roleElementIds,
                    CreateDate     = DateTime.Now,
                    CreateUserId   = entityRequest.CreateUserId,
                    CreateUserName = entityRequest.CreateUserName
                });
                await _employeeElementAppService.RemoveAsync(new EntityRequest()
                {
                    Ids            = empElementIds,
                    CreateDate     = DateTime.Now,
                    CreateUserId   = entityRequest.CreateUserId,
                    CreateUserName = entityRequest.CreateUserName
                });
            });

            return(resJson);
        }
        /// <summary>
        /// 删除机构
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <JsonResponse> RemoveOrganization(EntityRequest input)
        {
            var existsChild = await _organizationAppService.GetAnyByParentIdAsync(input.Id);

            if (existsChild)
            {
                return(JsonResponse.Create(false, "该机构有下级机构"));
            }
            var exitsEmp = await _relationOrganizationEmployeeAppService.GetAnyByOrganizationIdAsync(input.Id);

            if (exitsEmp)
            {
                return(JsonResponse.Create(false, "该机构有下有成员"));
            }
            input.Ids = new List <string>()
            {
                input.Id
            };
            var orgMenuIds = await _organizationMenuAppService.GetIdsByOrganizationIdsAsync(new List <string>() { input.Id });

            var orgElementIds = await _organizationElementAppService.GetIdsByOrganizationIdsAsync(new List <string>() { input.Id });

            var resJson = await _applicationEnginee.TryTransactionAsync(async() =>
            {
                await _organizationAppService.RemoveAsync(input);
                await _organizationMenuAppService.RemoveAsync(new EntityRequest()
                {
                    Ids            = orgMenuIds,
                    ModifyDate     = DateTime.Now,
                    ModifyUserId   = input.ModifyUserId,
                    ModifyUserName = input.ModifyUserName
                });
                await _organizationElementAppService.RemoveAsync(new EntityRequest()
                {
                    Ids            = orgElementIds,
                    ModifyDate     = DateTime.Now,
                    ModifyUserId   = input.ModifyUserId,
                    ModifyUserName = input.ModifyUserName
                });
            });

            return(resJson);
        }