public async Task <bool> UpdateCompanyDetailAsync(string simId, string industryTemplate, DateTime?updateTime = null) { var selectedRecord = _dbconCompany.Get(cd => cd.SimId.Equals(simId)).FirstOrDefault(); if (selectedRecord == null) { return(false); } selectedRecord.IndustryTemplate = industryTemplate; selectedRecord.LastUpdate = updateTime == null ? DateTime.Now : updateTime; return(await _dbconCompany.Update(selectedRecord.Id, selectedRecord)); }
private async Task <LastUpateCollectionMd> PopulateSymbolsToDbAsync(LastUpateCollectionMd lastUpdateDate) { var symbolsMd = _mapper.Map <List <SecuritySymbolMd> >(symbols); var updateResult = false; if (lastUpdateDate == null) { lastUpdateDate = new LastUpateCollectionMd { CollectionName = SecSymobls, LastUpdate = DateTime.Now }; lastUpdateDate = await _connectionHandlerLU.Create(lastUpdateDate); if (lastUpdateDate.Id.IsNullOrWhiteSpace()) { _logger.LogCritical("Could not insert record to collection LastUpdate"); } } else { lastUpdateDate.LastUpdate = DateTime.Now; updateResult = await _connectionHandlerLU.Update(lastUpdateDate.Id, lastUpdateDate); if (!updateResult) { _logger.LogCritical("Could not update record in LastUpdate"); } } updateResult = await _connectionHandlerSS.RemoveAll(); if (!updateResult) { _logger.LogCritical("Could delete all records in SecuritySymbol"); } updateResult = await _connectionHandlerSS.Create(symbolsMd); if (!updateResult) { _logger.LogCritical("Could insert records in SecuritySymbol"); } return(lastUpdateDate); }
/// <summary> /// Gets the out standing shares. /// </summary> /// <param name="simId">The sim identifier.</param> /// <returns></returns> public async Task <OutstandingShares> GetOutStandingShares(string simId) { var existingRecord = _dBConnection.Get(x => x.SimId == simId).FirstOrDefault(); if (existingRecord != null && existingRecord.LastUpdateDate != null && ((TimeSpan)(DateTime.Now - existingRecord.LastUpdateDate)).Days < validityOfRecord) { return(Mapper.Map <OutstandingSharesMd, OutstandingShares>(existingRecord)); } var externalData = await _dos.ObtainAggregatedList(simId); if (externalData == null) { _logger.LogError($"Could not download outstanding shares for SimId:{simId}"); return(null); } string id = ""; if (existingRecord != null) { id = existingRecord.Id; } existingRecord = Mapper.Map <OutstandingShares, OutstandingSharesMd>(externalData); existingRecord.LastUpdateDate = DateTime.Now; if (!id.IsNullOrWhiteSpace()) { existingRecord.Id = id; await _dBConnection.Update(id, existingRecord); } else { await _dBConnection.Create(existingRecord); } return(externalData); }