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);
        }
Example #2
0
        public async Task <IActionResult> EditProfile(string id, EditHardwareVaultProfileDto profileDto)
        {
            if (id != profileDto.Id)
            {
                return(BadRequest());
            }

            try
            {
                var profile = new HardwareVaultProfile()
                {
                    Id                     = profileDto.Id,
                    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
                };
                await _hardwareVaultService.EditProfileAsync(profile);

                _remoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await _hardwareVaultService.GetVaultIdsByProfileTaskAsync());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(500, new { error = ex.Message }));
            }

            return(NoContent());
        }