Ejemplo n.º 1
0
        public async Task<ActionResult<HardwareVaultProfile>> CreateProfile(CreateHardwareVaultProfileDto profileDto)
        {
            HardwareVaultProfile createdProfile;
            try
            {
                var deviceAccessProfile = new HardwareVaultProfile()
                {
                    Name = profileDto.Name,
                    ButtonPairing = profileDto.ButtonBonding,
                    ButtonConnection = profileDto.ButtonConnection,
                    ButtonStorageAccess = profileDto.ButtonNewChannel,
                    PinPairing = profileDto.PinBonding,
                    PinConnection = profileDto.PinConnection,
                    PinStorageAccess = profileDto.PinNewChannel,
                    MasterKeyConnection = profileDto.MasterKeyConnection,
                    MasterKeyStorageAccess = profileDto.MasterKeyNewChannel,
                    PinExpiration = profileDto.PinExpiration,
                    PinLength = profileDto.PinLength,
                    PinTryCount = profileDto.PinTryCount
                };
                createdProfile = await _hardwareVaultService.CreateProfileAsync(deviceAccessProfile);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return StatusCode(500, new { error = ex.Message });
            }

            return CreatedAtAction("GetProfileById", new { id = createdProfile.Id }, createdProfile);
        }