public void SetFxRate(IEnumerable <FXRateModel> fxRates) { using (var fxContext = new FXContext()) { foreach (var fxRateModel in fxRates) { var existingFx = fxContext.FXRateItems.FirstOrDefault(x => x.FXBase == fxRateModel.Base && x.FXSymbol == fxRateModel.Symbol); if (existingFx == null) { var fxRateEntity = new FXRateItem() { FXBase = fxRateModel.Base, FXSymbol = fxRateModel.Symbol, FXRateValue = fxRateModel.Rate }; fxContext.FXRateItems.Add(fxRateEntity); } else { existingFx.FXRateValue = fxRateModel.Rate; } } fxContext.SaveChanges(); } }
public RFIDController() { this.db = new FXContext(); }