public string InsertFeePreviewData(IEnumerable <FeePreviewDto> feePreviewDtos) { DateTime today = DateTime.UtcNow.Date; List <FeePreviewData> feePreviewDatas = feePreviewDtos .Select(s => s.Map()) .ToList(); List <FeePreviewData> enumeratedFeePreviewDatas = feePreviewDatas.Select(s => { s.Date = today; return(s); }).ToList(); using (AmazonMWSdbDataContext dc = m_amazonMWSdbDataContext.CreateWriteInstance()) { List <FeePreviewData> duplicateData = dc.FeePreviewDatas .Where(w => w.Date == today) .ToList(); if (!duplicateData.Any()) { // Batch Inventory insertion so as to avoid a SqlTimeoutException. foreach (IEnumerable <FeePreviewData> batchedFeePreview in enumeratedFeePreviewDatas.Batch(c_defaultBatchAmount)) { dc.FeePreviewDatas.InsertAllOnSubmit(batchedFeePreview); dc.SubmitChanges(); } } } return(string.Format("Distinct ASINs with Fee Preview: {0}", enumeratedFeePreviewDatas.Select(s => s.asin).Distinct().Count())); }
public void InsertListingOffersLog(List <ListingOffersLog> listingOffersLogs) { using (AmazonMWSdbDataContext dc = m_amazonMWSdbDataContext.CreateWriteInstance()) { foreach (IEnumerable <ListingOffersLog> batchedListingOffersLogs in listingOffersLogs.Batch(c_defaultBatchAmount)) { dc.ListingOffersLogs.InsertAllOnSubmit(batchedListingOffersLogs); dc.SubmitChanges(); } } }
public void InsertPriceHistory(List <PriceHistory> priceHistory) { using (AmazonMWSdbDataContext dc = m_amazonMWSdbDataContext.CreateWriteInstance()) { foreach (IEnumerable <PriceHistory> batchedPriceHistory in priceHistory.Batch(c_defaultBatchAmount)) { dc.PriceHistories.InsertAllOnSubmit(batchedPriceHistory); dc.SubmitChanges(); } } }
public string InsertUnsuppressedInventoryData(IEnumerable <UnsuppressedInventoryDto> unsuppressedInventoryDtos) { DateTime today = DateTime.UtcNow.Date; List <UnsuppressedInventoryData> unsuppressedInventoryDatas = unsuppressedInventoryDtos .Select(s => s.Map()) .ToList(); List <UnsuppressedInventoryData> enumeratedUnsuppressedInventoryDatas = unsuppressedInventoryDatas .Select(s => { s.Date = today; return(s); }) .ToList(); using (AmazonMWSdbDataContext dc = m_amazonMWSdbDataContext.CreateWriteInstance()) { List <UnsuppressedInventoryData> duplicateData = dc.UnsuppressedInventoryDatas .Where(w => w.Date == today) .ToList(); if (!duplicateData.Any()) { // Batch Inventory insertion so as to avoid a SqlTimeoutException. foreach (IEnumerable <UnsuppressedInventoryData> batchedInventory in enumeratedUnsuppressedInventoryDatas.Batch(c_defaultBatchAmount)) { dc.UnsuppressedInventoryDatas.InsertAllOnSubmit(batchedInventory); dc.SubmitChanges(); } } List <long?> fulfillableItems = enumeratedUnsuppressedInventoryDatas .GroupBy(g => g.asin) .Select(s => s.First().afn_fulfillable_quantity) .ToList(); return(string.Format("ASINs With Fulfillable Units: {0} \n Units Fulfillable: {1}", fulfillableItems.Count(w => w > 0), fulfillableItems.Sum())); } }