/// <summary>
        /// Add new identity resource
        /// </summary>
        /// <param name="identityResource"></param>
        /// <returns>This method return new identity resource id</returns>
        public async Task <IdentityResourceDTO> AddIdentityResourceAsync(IdentityResourceDTO dto)
        {
            var entity    = dto.ToEntity();
            var canInsert = await CanInsertIdentityResourceAsync(entity);

            if (!canInsert)
            {
                throw new Exception(Constants.Errors.CantInsert);
            }

            IdentityResources.Add(entity);

            await Context.SaveChangesAsync();

            return(entity.ToDTO());
        }
Пример #2
0
        public async Task <ActionResult <IdentityResourceDTO> > UpdateIdentityResourceAsync([FromBody] IdentityResourceDTO dto)
        {
            var result = await identityResourceService.UpdateIdentityResourceAsync(dto);

            return(Ok(result));
        }
Пример #3
0
 public static IdentityResource ToEntity(this IdentityResourceDTO dto)
 {
     return(dto == null ? null : Mapper.Map <IdentityResource>(dto));
 }