Ejemplo n.º 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.FirstOrDefault();

            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 <ClaimTypeParam, ClaimType>(model, entity);
            await _repository.UpdateAsync(entity);

            return(entity.Id);
        }
Ejemplo n.º 2
0
 private ClaimTypeInfo ToInfo(ClaimType entity)
 {
     return(SimpleMapper.From <ClaimType, ClaimTypeInfo>(entity));
 }