private IVmOpenApiServiceChannelBase GetAndUpdateServiceChannel(IDataMapper mapper, int channelId) { IVmOpenApiServiceChannelBase vmResult = new VmOpenApiServiceLocationChannelVersionBase(); if (alreadyUpdatedChannels.Contains(channelId)) { // The channel was already updated so lets just get the corresponding guid for source id. if (!Settings.DebugData) { vmResult.Id = channelService.GetServiceChannelBySource(channelId.ToString(), UserName); } } else { try { var vmChannel = mapper.MapServiceChannel(channelId); if (!Settings.DebugData) { if (PostalCodeExists(vmChannel.Addresses)) { try { vmResult = channelService.AddServiceChannel(vmChannel, false, 0, UserName); } catch (ExternalSourceExistsException ex) { // The external source for service channel is already in use so the item was already created into PTV. Let's update the data. vmResult = channelService.SaveServiceChannel(vmChannel, false, 0, UserName); } } } alreadyUpdatedChannels.Add(channelId); } catch (Exception ex) { logger.LogError($"Error occured while updating a channel { channelId }. { ex.Message }."); //throw ex; } } return(vmResult); }