/// <summary> /// Write to data source /// </summary> /// <param name="operation">contians the operation to be written</param> /// <returns></returns> public OperationResult WriteToDataSource(WriteOperation operation) { if (operation == null) { throw new ArgumentNullException(nameof(operation)); } OperationResult operationResults = new OperationResult(operation, OperationResult.Status.Success); try { switch (operation.OperationType) { case WriteOperationType.Add: var items = new Dictionary <string, ProviderItemBase>(); items.Add(operation.Key, operation.ProviderItem); PersistenceProvider.Add(items); break; case WriteOperationType.Update: var itemsToUpdate = new Dictionary <string, ProviderItemBase>(); itemsToUpdate.Add(operation.Key, operation.ProviderItem); PersistenceProvider.Insert(itemsToUpdate); break; case WriteOperationType.Delete: PersistenceProvider.Remove(new string[] { operation.Key }); break; } } catch (Exception ex) { Logger.LogError(ex.ToString()); operationResults = new OperationResult(operation, OperationResult.Status.Failure); } return(operationResults); }