private void SetReferenceData(BicycleQuote model) { ViewData.SetReferenceData(_quoteFormHandler.CreateReferenceData()); MinMaxDTO minMax = _referenceDataService.GetSumInuredRange(); if (minMax.MinValue != null) { model.Quote.Options[0].SumInsured.MinValue = (int)minMax.MinValue; } if (minMax.MaxValue != null) { model.Quote.Options[0].SumInsured.MaxValue = (int)minMax.MaxValue; } }
public async Task <MinMaxDTO> GetSumInuredRange() { using (InsuranceDbContext context = _contextFactory.CreateContext()) { List <CoverOption> options = await context.CoverOptions.ToListAsync(); MinMaxDTO result = new MinMaxDTO { MinValue = options.Min(x => x.MinimumAgreedValue), MaxValue = options.Max(x => x.MaximumAgreedValue) }; return(result); } }