public ExchangeRateModel( IYearInfoService infoService, RateDBContext context, RateCache rateCache) { this.infoService = infoService; this.context = context; this.rateCache = rateCache; }
public PK AddPK(DateTime beginTime) { using (var db = new RacingDbContext()) { var pk = new PK { CreateTime = DateTime.Now, BeginTime = beginTime, EndTime = DateTime.Now.AddSeconds(AppConfigCache.Racing_Total_Seconds), OpeningSeconds = AppConfigCache.Racing_Opening_Seconds, CloseSeconds = AppConfigCache.Racing_Close_Seconds, GameSeconds = AppConfigCache.Racing_Game_Seconds, LotterySeconds = AppConfigCache.Racing_Lottery_Seconds, //PKRates = pkRates //pkRates 过多, 插入时间很长, 必须和PK新增分开 }; db.PK.Add(pk); db.SaveChanges(); // pkRates 过多, 插入时间很长, 必须和PK新增分开 var pkRates = new List <PKRate>(); foreach (var rate in RateCache.GetRatesByType(Data.Enums.RateType.Arena)) { for (var num = 1; num <= 14; num++) { pkRates.Add(new PKRate { PKId = pk.PKId, Rank = rate.Rank, Num = num, Rate = RateService.GetRate(rate, num) }); } } db.PKRate.AddRange(pkRates); db.SaveChanges(); return(pk); } }