Esempio n. 1
0
        public async Task<IHttpActionResult> Create(CreateRoleBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var role = new IdentityRole { Name = model.Name };

            var result = await this.AppRoleManager.CreateAsync(role);

            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }

            Uri locationHeader = new Uri(Url.Link("GetRoleById", new { id = role.Id }));

            return Created(locationHeader, TheModelFactory.Create(role));

        }
Esempio n. 2
0
 public RoleReturnModel Create(IdentityRole appRole)
 {
     return new RoleReturnModel
     {
         Url = _UrlHelper.Link("GetRoleById", new { id = appRole.Id }),
         Id = appRole.Id,
         Name = appRole.Name
     };
 }