/// <summary> /// Stores the specified value. /// </summary> /// <param name="value">The value.</param> public void Save(StorableTaggedFile value) { #if DEBUG var sw = Stopwatch.StartNew(); #endif var existingFile = fileAdapter.GetFirstById(value.Id); if (null != existingFile) { existingFile = existingFile.LoadReferences(referenceAdapters); UpdateConditional(existingFile, value); value = existingFile; fileAdapter.Delete(existingFile); } else { value.Title = GetTitle(value); value.Album = GetAlbum(value); value.Genre = GetGenre(value); value.Artist = GetArtist(value); value.Year = GetYear(value); } fileAdapter.Save(value); CommitToCache(value); #if DEBUG sw.Stop(); ++persisted; totalTime += sw.Elapsed; if (DateTime.Now - lastTime < TimeSpan.FromSeconds(2)) { return; } Trace.WriteLine(string.Format("Persister: ~{0} Items/sec", persisted / totalTime.TotalSeconds)); lastTime = DateTime.Now; #endif }
public IActionResult Delete([FromRoute] int id) { if (_adapter.Delete(id)) { return(Ok()); } else { return(NotFound()); } }
public ActionResult <Result> Delete(string key, int itemId) { dataAdapter.Delete(x => x.ItemId == itemId && x.Key == key); return(Result.GenerateResult(200, itemId)); }
public ActionResult <Result> DeletePortfolio(string key, int portfolioId) { dataAdapter.Delete(x => x.PortfolioId == portfolioId && x.Key == key); return(Result.GenerateResult(200, portfolioId)); }
public T Remove <T>(T entity) where T : class => adapter.Delete(entity);