public List <PowerPort> Resolve(PowerConnectionDto source, PowerConnection destination, List <PowerPort> destMember, ResolutionContext context) { return(source.Ports.Select <PowerPortDto, PowerPort>(powerPort => { // use the appropriate repository method for the given type of power port return powerPort switch { AssetPowerPortDto _ => _powerRepo.GetAssetPowerPort(powerPort.Id), PduPortDto _ => _powerRepo.GetPduPort(powerPort.Id), _ => throw new ArgumentException($"Unsupported power port type: {powerPort.GetType()}", nameof(powerPort)) }; }) .ToList()); }
public void Process(AssetPowerPortDto source, AssetPowerPort destination, ResolutionContext context) { if (!source.PduPortId.HasValue) { return; } destination.PowerConnection = new PowerConnection { Ports = new List <PowerPort> { destination, _repo.GetPduPort(source.PduPortId.Value) } }; }
public PduPortDto GetPduPort(Guid rackId, PduLocation pduLocation, int portNumber) { var port = _repository.GetPduPort(rackId, pduLocation, portNumber); return(_mapper.Map <PduPortDto>(port)); }