Пример #1
0
        public async Task <ResponseBase <bool> > Create(CreateRoleInput input)
        {
            if ((await _roleManager.FindByNameAsync(input.Name)) != null)
            {
                return(new ResponseBase <bool>()
                {
                    Result = false, Message = "Role Exsit"
                });
            }
            var role = _mapper.Map <IdentityRole>(input);
            await _roleManager.CreateAsync(role);

            var claims = _mapper.Map <IList <IdentityRoleClaim <string> > >(input.RoleClaims).Select(a => { a.RoleId = role.Id; return(a); }).ToList();
            await _roleRepository.AddClaims(claims);

            return(new ResponseBase <bool>()
            {
                Result = true
            });
        }