示例#1
0
        public async Task <Guid> CreateAsync(ClaimTypeParam model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var items = await _repository.ListAsync(new ClaimTypeByName(model.Name));

            var entity = items.Count > 0 ? items[0] : null;

            if (entity == null)
            {
                // create new entity
                var newEntity = ClaimType.Create(
                    model.Name,
                    model.ClaimValueType,
                    model.Description
                    );
                await _repository.AddAsync(newEntity);

                return(newEntity.Id);
            }

            // update existing entity
            model.Id = entity.Id;
            SimpleMapper.Map(model, entity);
            await _repository.UpdateAsync(entity);

            return(entity.Id);
        }
示例#2
0
 private static ClaimTypeInfo ToInfo(ClaimType entity)
 {
     return(SimpleMapper.From <ClaimType, ClaimTypeInfo>(entity));
 }