public static async Task AddCorrelatedIncrease(CorrelatedIncrease increase) { using (var context = new SqliteContext()) { var increaseInDb = context.CorrelatedIncrease .Where(w => w.PrimaryFundDayID == increase.PrimaryFundDayID) .Where(w => w.SecondaryFundDayID == increase.SecondaryFundDayID) .FirstOrDefault(); if (increaseInDb == null || increaseInDb.CorrelatedIncreaseID == 0) { await AddEntity(increase); } } }
public static async Task AddFundDays(List <FundDay> days, DateTime?earliestDate = null) { if (!earliestDate.HasValue) { earliestDate = DateTime.MinValue; } using (var context = new SqliteContext()) { foreach (var day in days) { var dayInDb = context.FundDay.Where(w => w.Symbol == day.Symbol && w.FundDayDate == day.FundDayDate).FirstOrDefault(); if (dayInDb == null && day.FundDayDate >= earliestDate) { if (day.Open != 0.0M) { day.Delta = ((day.Close - day.Open) / day.Open); } await AddEntity(day); } } } }