public IActionResult PreBooking() { #region lay session SearchVM Request = HttpContext.Session.GetObject <SearchVM>(SessionManager.Request); BookingVM b = HttpContext.Session.GetObject <BookingVM>(SessionManager.Booking); #endregion #region tao model PreBookingVM model = new PreBookingVM(); model.Request = Request; model.Tickets.Add(_item.GetItemById(b.VeDi)); FareVM DepartFare = new FareVM(); DepartFare.DanhSach.Add(new Fare() { HanhKhach = "Người lớn", SoLuong = Request.NguoiLon, GiaVe = Request.NguoiLon * _item.GetDiscount(b.VeDi, 1) * model.Tickets[0].Gia }); DepartFare.DanhSach.Add(new Fare() { HanhKhach = "Trẻ em", SoLuong = Request.TreEm, GiaVe = Request.TreEm * _item.GetDiscount(b.VeDi, 2) * model.Tickets[0].Gia }); DepartFare.DanhSach.Add(new Fare() { HanhKhach = "Em bé", SoLuong = Request.EmBe, GiaVe = Request.EmBe * _item.GetDiscount(b.VeDi, 3) * model.Tickets[0].Gia }); model.Fares.Add(DepartFare); model.HanhLyXT.Add((int)_context.ChiTietHangVe.Where(s => s.id_HangVe == Request.HangVe && s.id_HangBay == _item.GetIdHangBay(b.VeDi)).Select(s => s.HanhLyXt).SingleOrDefault()); if (b.VeVe != -1) { model.Tickets.Add(_item.GetItemById(b.VeVe)); FareVM ReturnFare = new FareVM(); DepartFare.DanhSach.Add(new Fare() { HanhKhach = "Người lớn", SoLuong = Request.NguoiLon, GiaVe = Request.NguoiLon * _item.GetDiscount(b.VeVe, 1) * model.Tickets[1].Gia }); DepartFare.DanhSach.Add(new Fare() { HanhKhach = "Trẻ em", SoLuong = Request.TreEm, GiaVe = Request.TreEm * _item.GetDiscount(b.VeVe, 2) * model.Tickets[1].Gia }); DepartFare.DanhSach.Add(new Fare() { HanhKhach = "Em bé", SoLuong = Request.EmBe, GiaVe = Request.EmBe * _item.GetDiscount(b.VeVe, 3) * model.Tickets[1].Gia }); model.Fares.Add(ReturnFare); model.HanhLyXT.Add((int)_context.ChiTietHangVe.Where(s => s.id_HangVe == Request.HangVe && s.id_HangBay == _item.GetIdHangBay(b.VeVe)).Select(s => s.HanhLyXt).SingleOrDefault()); } #endregion return(View(model)); }