Exemplo n.º 1
0
        public async Task <CreateAttributeCommandResult> Handle(CreateAttributeCommand command, CancellationToken cancellationToken)
        {
            var attributeType = AttributeType.FromName(command.Attribute.Type.ToString());
            var attribute     = attributeType.CreateAttribute(command.Attribute.Name, command.Attribute.Description);

            var newAttribute = await _unitOfWork.AttributeRepository.AddAsync(attribute);

            await _unitOfWork.SaveEntitiesAsync(cancellationToken);

            return(new CreateAttributeCommandResult(new AttributeWithIdentityDto
            {
                Id = newAttribute.Id,
                Type = command.Attribute.Type,
                Name = command.Attribute.Name,
                Description = command.Attribute.Description
            }));
        }