Exemplo n.º 1
0
        public async Task DeleteRoleAsync(RoleDeleteDto role)
        {
            //remove time portion
            role.EndDate = role.EndDate?.Date;

            var roleEntity = await DbSet
                             .FirstAsync(x => x.RoleId == role.RoleId);

            Mapper.Map(role, roleEntity);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> DeleteRole(RoleDeleteDto roleDeleteDto)
        {
            var role = await _roleManager.FindByNameAsync(roleDeleteDto.RoleName);

            if (role == null)
            {
                return(BadRequest("Role deos not exist"));
            }
            await _roleManager.DeleteAsync(role);

            return(Ok(_roleManager.Roles.ToList()));
        }
Exemplo n.º 3
0
        public async Task <ApiResult> RoleDelete(RoleDeleteDto input)
        {
            using var tran = await unitofWork.BeginTransactionAsync();

            var role = await rolerepository.GetAsync(input.RoleId);

            if (role == null)
            {
                throw new ApplicationServiceException("所选角色不存在!");
            }
            rolerepository.Delete(role);
            if (await new RoleDeleteCheckSpecification(rolerepository).IsSatisfiedBy(role))
            {
                await unitofWork.CommitAsync(tran);
            }
            return(ApiResult.Ok("角色删除成功"));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> DeleteRole(decimal id, RoleDeleteDto role)
        {
            if (id != role.RoleId)
            {
                throw new Exception($"The system role ID from the query string does not match that of the body.");
            }

            var response = await _roleSvc.DeleteRoleAsync(role);

            if (response.NotFound)
            {
                return(NotFound());
            }

            if (response.Errors.Count > 0)
            {
                return(ValidationUtils.GetValidationErrorResult(response.Errors, ControllerContext));
            }

            return(NoContent());
        }