public CtrlInsuranceDto GetCtrlInsurance() { var model = InsuranceSection.GetInsuranceConfigurationSection(); if (model == null) { return(null); } var m = new CtrlInsuranceDto { IsEnabled = model.CtrlInsuranceCollection.IsEnabled, SinglePrice = model.CtrlInsuranceCollection.SinglePrice, CtrlInsurance = new List <CtrlInsuranceConfig>() }; foreach (var cfg in from InsuranceElement ctrl in model.CtrlInsuranceCollection select new CtrlInsuranceConfig { LeaveCount = ctrl.LeaveCount, IsCurrent = ctrl.IsCurrent, Value = ctrl.Value }) { m.CtrlInsurance.Add(cfg); } return(m); }
public void SaveCtrlConfig(CtrlInsuranceDto dto) { var model = InsuranceSection.GetInsuranceConfigurationSection(); if (model == null || model.CtrlInsuranceCollection == null) { return; } model.CtrlInsuranceCollection.IsEnabled = dto.IsEnabled; model.CtrlInsuranceCollection.SinglePrice = dto.SinglePrice; foreach (InsuranceElement ctrl in model.CtrlInsuranceCollection) { foreach (var m in dto.CtrlInsurance.Where(m => ctrl.Value.Trim().Equals(m.Value, StringComparison.InvariantCultureIgnoreCase))) { ctrl.IsCurrent = m.IsCurrent; ctrl.LeaveCount = m.LeaveCount; } } InsuranceSection.Save(); }