public IActionResult Order(ReportModel model) { var paymentList = new List <PaymentViewModel>(); var orders = new List <OrderViewModel>(); orders = _orderLogic.Read(new OrderBindingModel { ClientId = Program.Client.Id, Date = model.From, DateTo = model.To }); var payments = _paymentLogic.Read(null); foreach (var order in orders) { foreach (var payment in payments) { if (payment.ClientId == Program.Client.Id && payment.OrderId == order.Id) { paymentList.Add(payment); } } } ViewBag.Payments = paymentList; ViewBag.Orders = orders; string fileName = "C:\\Users\\Михан\\Desktop\\data\\pdfreport.pdf"; if (model.SendMail) { _reportLogic.SaveOrderPaymentsToPdfFile(fileName, new OrderBindingModel { ClientId = Program.Client.Id, Date = model.From, DateTo = model.To }, Program.Client.Email); } else { _reportLogic.SaveOrderPaymentsToPdfFile(fileName, new OrderBindingModel { ClientId = Program.Client.Id, Date = model.From, DateTo = model.To }, null); } return(View()); }