private static SmpConfigurationDetail ToDetail(Entities.SmpConfiguration s) { return(new SmpConfigurationDetail { Id = s.Id, Action = s.Action, ServiceType = s.ServiceType, ServiceValue = s.ServiceValue, FinalRecipient = s.FinalRecipient, ToPartyId = s.ToPartyId, PartyRole = s.PartyRole, TlsEnabled = s.TlsEnabled, Url = s.Url, PartyType = s.PartyType, EncryptionEnabled = s.EncryptionEnabled, EncryptAlgorithm = s.EncryptAlgorithm, EncryptAlgorithmKeySize = s.EncryptAlgorithmKeySize, EncryptKeyDigestAlgorithm = s.EncryptKeyDigestAlgorithm, EncryptKeyMgfAlorithm = s.EncryptKeyMgfAlorithm, EncryptKeyTransportAlgorithm = s.EncryptKeyTransportAlgorithm, EncryptPublicKeyCertificate = s.EncryptPublicKeyCertificate == null ? null : Convert.ToBase64String(s.EncryptPublicKeyCertificate), EncryptPublicKeyCertificateName = s.EncryptPublicKeyCertificateName }); }
/// <summary> /// Get SMP configuration by identifier /// </summary> /// <returns> /// Matched <see cref="N:Eu.EDelivery.AS4.Fe.Model.SmpConfigurationDetail" /> if found /// </returns> public async Task <SmpConfigurationDetail> GetByIdAsync(int id) { Entities.SmpConfiguration entity = await _datastoreContext .SmpConfigurations .FirstOrDefaultAsync(s => s.Id == id); if (entity == null) { return(null); } return(ToDetail(entity)); }
/// <summary> /// Update an existing <see cref="N:Eu.EDelivery.AS4.Fe.Model.SmpConfigurationDetail" /> by id /// </summary> /// <param name="id">The id of the SmpConfiguration</param> /// <param name="detail">SMP configuration data to be updated</param> /// <returns></returns> /// <exception cref="NotFoundException"></exception> public async Task UpdateAsync(long id, SmpConfigurationDetail detail) { EnsureArg.IsNotNull(detail, nameof(detail)); EnsureArg.IsTrue(id > 0, nameof(id)); ValidateSmpConfiguration(detail); Entities.SmpConfiguration existing = await _datastoreContext .SmpConfigurations .FirstOrDefaultAsync(c => c.Id == id); if (existing == null) { throw new NotFoundException($"No smp configuration with id {id} found."); } _mapper.Map(detail, existing); existing.EncryptPublicKeyCertificate = DeserializePublicKeyCertificate(detail.EncryptPublicKeyCertificate); _datastoreContext.Entry(existing).State = EntityState.Modified; await _datastoreContext.SaveChangesAsync(); }