public IActionResult Education(ReportModel model) { var paymentList = new List <PaymentViewModel>(); var educations = new List <EducationViewModel>(); educations = _educationLogic.Read(new EducationBindingModel { ClientId = Program.Client.Id, DateFrom = model.From, DateTo = model.To }); var payments = _paymentLogic.Read(null); foreach (var education in educations) { foreach (var payment in payments) { if (payment.ClientId == Program.Client.Id && payment.EducationId == education.Id) { paymentList.Add(payment); } } } ViewBag.Payments = paymentList; ViewBag.Educations = educations; string fileName = "C:\\data\\pdfreport.pdf"; if (model.SendMail) { _reportLogic.SaveEducationPaymentsToPdfFile(fileName, new EducationBindingModel { ClientId = Program.Client.Id, DateFrom = model.From, DateTo = model.To }, Program.Client.Email); } return(View()); }