private async Task <ActionResult <CommandLogDto> > UpdateDb(IApiCalls apiCalls) { DateTime lastUpdateTime = _repo.GetLatestLog().LastUpdate; if (DateTime.Now < lastUpdateTime.AddHours(1)) { return(NoContent()); } _repo.ClearListings(); IEnumerable <Listing> listingsToAdd = await apiCalls.GetAllListings(); _repo.AddListings(listingsToAdd); CommandLog commandLog = new CommandLog(); commandLog.Deleted = (_repo.GetRecipePricesCount() + _repo.GetTpPricesCount()); commandLog.CommandExecuted = "update"; commandLog.LastUpdate = DateTime.Now; commandLog.Inserted = _repo.GetListingsCount(); _repo.AddCommandLog(commandLog); SetAllRecipesCreationPrice(); if (_repo.SaveChanges()) { //return NotFound(); CommandLogDto commandLogDto = _mapper.Map <CommandLogDto>(commandLog); //TODO: change to add rout in response header return(Ok(commandLogDto)); } return(NotFound()); }