Ejemplo n.º 1
0
        public IActionResult RoundTripConfirm()
        {
            #region lay session
            BookingVM b       = HttpContext.Session.GetObject <BookingVM>(SessionManager.Booking);
            SearchVM  Request = HttpContext.Session.GetObject <SearchVM>(SessionManager.Request);
            #endregion

            #region tao model tra ve
            ConfirmVM model = new ConfirmVM();
            model.Request = Request;
            model.Tickets.Add(_item.GetItemById(b.VeDi));
            model.Tickets.Add(_item.GetItemById(b.VeVe));

            FareVM DepartFares = new FareVM();
            DepartFares.DanhSach.Add(new Fare()
            {
                HanhKhach = "Người lớn", SoLuong = Request.NguoiLon, GiaVe = model.Tickets[0].Gia * _item.GetDiscount(b.VeDi, 1)
            });
            DepartFares.DanhSach.Add(new Fare()
            {
                HanhKhach = "Trẻ em", SoLuong = Request.TreEm, GiaVe = model.Tickets[0].Gia * _item.GetDiscount(b.VeDi, 2)
            });
            DepartFares.DanhSach.Add(new Fare()
            {
                HanhKhach = "Em bé", SoLuong = Request.EmBe, GiaVe = model.Tickets[0].Gia * _item.GetDiscount(b.VeDi, 3)
            });
            FareVM ReturnFares = new FareVM();
            ReturnFares.DanhSach.Add(new Fare()
            {
                HanhKhach = "Người lớn", SoLuong = Request.NguoiLon, GiaVe = model.Tickets[1].Gia * _item.GetDiscount(b.VeVe, 1)
            });
            ReturnFares.DanhSach.Add(new Fare()
            {
                HanhKhach = "Trẻ em", SoLuong = Request.TreEm, GiaVe = model.Tickets[1].Gia * _item.GetDiscount(b.VeVe, 2)
            });
            ReturnFares.DanhSach.Add(new Fare()
            {
                HanhKhach = "Em bé", SoLuong = Request.EmBe, GiaVe = model.Tickets[1].Gia * _item.GetDiscount(b.VeVe, 3)
            });
            model.Fares.Add(DepartFares);
            model.Fares.Add(ReturnFares);

            model.Planes.Add(_context.ChiTietChuyenBay.Include(c => c.ChiTietGhe).ThenInclude(h => h.HangVe)
                             .Where(c => c.ChiTietGhe.HangVe.id_HangVe == Request.HangVe && c.id_ChiTietChuyenBay == b.VeDi)
                             .Select(c => new PlaneVM()
            {
                SoDoGhe = c.ChiTietGhe.SoDoGhe, KhoangCach = (int)c.ChiTietGhe.KhoangCach, TenMayBay = "Airbus 330"
            }).SingleOrDefault());
            model.Planes.Add(_context.ChiTietChuyenBay.Include(c => c.ChiTietGhe).ThenInclude(h => h.HangVe)
                             .Where(c => c.ChiTietGhe.HangVe.id_HangVe == Request.HangVe && c.id_ChiTietChuyenBay == b.VeVe)
                             .Select(c => new PlaneVM()
            {
                SoDoGhe = c.ChiTietGhe.SoDoGhe, KhoangCach = (int)c.ChiTietGhe.KhoangCach, TenMayBay = "Boeing 717"
            }).SingleOrDefault());
            #endregion

            return(PartialView("_RoundTripConfirm", model));
        }
        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));
        }