public SearchRequestDb SaveRequest(SearchRequestDb request) { var videosFromDb = new List <ResultVideoDb>(); foreach (var video in request.Videos) { videosFromDb.Add(_context.Videos.Find(video.Id)); } request.Videos = videosFromDb; _context.SearchRequests.Add(request); _context.SaveChanges(); return(request); }
public SearchRequestDb Update(SearchRequestDb request) { var requestFromDb = _context.SearchRequests.Find(request.Id); var videosFromDb = new List <ResultVideoDb>(); foreach (var video in request.Videos) { videosFromDb.Add(_context.Videos.Find(video.Id)); } requestFromDb.Videos = videosFromDb; _context.Entry(requestFromDb).State = EntityState.Modified; _context.SaveChanges(); return(requestFromDb); }
public bool Exists(SearchRequestDb searchRequest) { return(_context.SearchRequests.Any(r => r.CacheId == searchRequest.CacheId)); }