public void Remove(ISection section, Action <OnCompleteEventArgs> onComplete) { if (!IsOpened) { _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Error, "Сперва необходимо открыть репозиторий!"))); } else { _backWorker.AddWork( () => { try { var devInfosToRemove = _deviceInformationStorage.DeviceInformations.Where(di => di.Id.ToString() == section.DeviceInformationId.ToString()).ToList(); foreach (var devInfo in devInfosToRemove) { IDeviceInformation info = devInfo; // for closure var idsToRemove = _psnDataInformtationStorage.PsnDataInformations.Where(pdi => pdi.DeviceInformationId == info.Id).Select(pdi => pdi.Id).ToList(); foreach (var idToRemove in idsToRemove) { _psnDataStorage.Remove(idToRemove); _psnDataInformtationStorage.Remove(idToRemove); _psnDataCustomConfigurationsStorage.Remove(idToRemove); } // TODO: remove RPD logs _deviceInformationStorage.Remove(devInfo.Id); } UpdateLocomotivesIfDeletedUnsafe(); _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Ok, "Секция удалена из репозитория"))); } catch (Exception ex) { _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Error, ex.ToString()))); } }); } }
public void Remove(IIdentifier psnLogInformationId) { _relayOnStorage.Remove(psnLogInformationId); var infosToRemove = _psnDataInformations.Where(i => i.Id.ToString() == psnLogInformationId.ToString()).ToList(); foreach (var psnDataInformation in infosToRemove) { _psnDataInformations.Remove(psnDataInformation); } }