Example #1
0
        public async Task <string> Add(AddRoleInputDto model)
        {
            log.LogInformation("Adding role {0}", model.Name);

            bool roleExists = await roleManager.RoleExistsAsync(model.Name);

            if (roleExists)
            {
                throw new Exception(String.Format("Role '{0}' already exists!", model.Name));
            }

            var role = new ApplicationRole(model.Name);
            await roleManager.CreateAsync(role);

            return(role.Id);
        }
Example #2
0
        public async Task <ActionResult <string> > Add(AddRoleInputDto model)
        {
            var roleId = await rolesService.Add(model);

            return(CreatedAtAction(nameof(Get), new { id = roleId }, new { id = roleId }));
        }