public DeleteResult Delete(TKey id) { if (_inmemoryCollection.IsActive) { return(new DeleteResult { Ok = true, DocumentsAffected = _inmemoryCollection.Delete(id) ? 1 : 0 }); } return(_storage.Delete(id)); }
public void can_delete_by_id() { var model = new SampleReadModelWithStringKey() { Id = "a" }; _inmemoryCollection.Save(model); _inmemoryCollection.Delete("a"); Assert.AreEqual(0, _inmemoryCollection.GetAll().Count()); }
public DeleteResult Delete(TKey id) { if (_inmemoryCollection.IsActive) { var instance = _inmemoryCollection.GetById(id); _indexes.RemoveInstance(instance); return(new DeleteResult { Ok = true, DocumentsAffected = _inmemoryCollection.Delete(id) ? 1 : 0 }); } return(_storage.Delete(id)); }
public async Task <DeleteResult> DeleteAsync(TKey id) { if (_inmemoryCollection.IsActive) { var instance = _inmemoryCollection.GetById(id); _indexes.RemoveInstance(instance); return(new DeleteResult { Ok = true, DocumentsAffected = _inmemoryCollection.Delete(id) ? 1 : 0 }); } return(await _storage.DeleteAsync(id).ConfigureAwait(false)); }