Ejemplo n.º 1
0
 private KeyValuePair <DateTime, double> InsertAssetValueForPreviousDaysWithoutMarketValues(DomainObjects.Asset.Asset asset, KeyValuePair <DateTime, double>?previousDateAndValue, KeyValuePair <DateTime, double> currentPendingDateAndValue)
 {
     if (previousDateAndValue.HasValue && previousDateAndValue?.Key > DateTime.MinValue)
     {
         var previousDate = previousDateAndValue?.Key.AddDays(1);
         while (previousDate < currentPendingDateAndValue.Key)
         {
             var previousAssetValue = new DomainObjects.Asset.AssetValue()
             {
                 AssetId = asset.Id, Date = previousDate.Value, Value = previousDateAndValue.Value.Value
             };
             Data.Insert(previousAssetValue);
             previousDate = previousDate.Value.AddDays(1);
         }
     }
     return(currentPendingDateAndValue);
 }
Ejemplo n.º 2
0
        private void CreateAssetValueForPendingDates(DomainObjects.Asset.Asset asset, DateTime lastUpdatedValue, Dictionary <DateTime, double> assetDateAndValues)
        {
            var pendingUpdate        = assetDateAndValues?.Where(d => d.Key > lastUpdatedValue).OrderBy(v => v.Key);
            var previousDateAndValue = assetDateAndValues?.Where(d => d.Key == lastUpdatedValue).OrderByDescending(v => v.Key).FirstOrDefault();

            if (pendingUpdate != null)
            {
                foreach (var pending in pendingUpdate)
                {
                    previousDateAndValue = InsertAssetValueForPreviousDaysWithoutMarketValues(asset, previousDateAndValue, pending);
                    var assetValue = new DomainObjects.Asset.AssetValue()
                    {
                        AssetId = asset.Id, Date = pending.Key, Value = pending.Value
                    };
                    Data.Insert(assetValue);
                }
            }
        }