public async Task InsertAsync(ISwiftCredentials swiftCredentials) { var entity = new SwiftCredentialsEntity { PartitionKey = GetPartitionKey(swiftCredentials.RegulatorId), RowKey = GetRowKey(swiftCredentials.AssetId) }; Mapper.Map(swiftCredentials, entity); try { await _storage.InsertAsync(entity); } catch (StorageException exception) { if (exception.RequestInformation != null && exception.RequestInformation.HttpStatusCode == 409 && exception.RequestInformation.ExtendedErrorInformation.ErrorCode == TableErrorCodeStrings.EntityAlreadyExists) { throw new SwiftCredentialsAlreadyExistsException("Already exists", exception) { RegulationId = swiftCredentials.RegulatorId, AssetId = swiftCredentials.AssetId }; } } }
public async Task <bool> UpdateAsync(ISwiftCredentials swiftCredentials) { SwiftCredentialsEntity swiftCredentialsEntity = await _storage.MergeAsync( GetPartitionKey(swiftCredentials.RegulatorId), GetRowKey(swiftCredentials.AssetId), entity => { Mapper.Map(swiftCredentials, entity); return(entity); }); return(swiftCredentialsEntity != null); }