public async Task <IActionResult> Index(int appointmentId) { CreditCard.AppointmentId = appointmentId; var idd = HttpContext.Session.Get <Dictionary <int, int> >("ls")[int.MaxValue]; if (CreditCard.AppointmentId != idd) { return(NotFound()); } List <ProductsSelectedForAppointment> psd = new List <ProductsSelectedForAppointment>(); if (orm == 1) { CreditCard.Appointments = qdb.retAppointment(appointmentId); psd = qdb.retpsa_with_ai(appointmentId); foreach (ProductsSelectedForAppointment i in psd) { qdb.include_pi_ai(i); } } else { CreditCard.Appointments = await _db.Appointments.FirstAsync(i => i.Id == appointmentId); psd = _db.ProductsSelectedForAppointments.Where(e => e.AppointmentId == appointmentId).Include(e => e.Products).ToList(); } double price = 0; foreach (ProductsSelectedForAppointment i in psd) { price += i.Products.Price * i.Count; } CreditCard.SalePrice = Convert.ToDecimal(price); return(View(CreditCard)); }