Esempio n. 1
0
        public async Task <ActionResult> AddRole([FromBody] RoleDto roleViewModel)
        {
            IdentityRole newRole = new IdentityRole();

            roleViewModel.UpdateIdentityRole(newRole);
            var createUserResult = await this._identityService.CreateRoleAsync(newRole);

            if (createUserResult.Succeeded)
            {
                // return CreatedAtAction(nameof(ReturnRole), new { id = newRole.Id }, newRole);
                return(Ok());
            }

            throw new Exception("Failed to add Role");
        }
Esempio n. 2
0
        public async Task <ActionResult> UpdateRole([FromBody] RoleDto roleViewModel)
        {
            var currentRole = await this._identityService.ReturnRoleAsync(roleViewModel.Id.Value);

            if (currentRole == null)
            {
                return(NotFound());
            }

            roleViewModel.UpdateIdentityRole(currentRole);

            await this._identityService.UpdateRoleAsync(currentRole);

            return(NoContent());
        }