Beispiel #1
0
        public ActionResult KiemTraChoNgoi(int NguonVeXeId, int ParentId, long NgayDi, string KyHieuGhe, string Tang)
        {
            // This action method gets called via an ajax request
            if (String.IsNullOrEmpty(KyHieuGhe) || String.IsNullOrEmpty(Tang))
            {
                throw new ArgumentNullException("KiemTraChoNgoi");
            }
            if (Session["DAT_MUA_VE_XE_ID"] == null)
            {
                return(Loi());
            }
            var item = new PhoiVe();

            item.NguonVeXeId = NguonVeXeId;
            //neu la ve con, thi lay ve cha lam phieu dat ve
            if (ParentId > 0)
            {
                item.NguonVeXeId    = ParentId;
                item.NguonVeXeConId = NguonVeXeId;
            }

            item.NgayDi = new DateTime(NgayDi);
            var nguonvexe = _vexeService.GetNguonVeXeById(item.NguonVeXeId.GetValueOrDefault(0));

            item.SoDoGheXeQuyTacId = _vexeService.GetSoDoGheXeQuyTacID(nguonvexe.LoaiXeId, KyHieuGhe, Convert.ToInt32(Tang));
            if (item.SoDoGheXeQuyTacId > 0)
            {
                item.TrangThai    = ENTrangThaiPhoiVe.DatCho;
                item.isChonVe     = true; //giao dich nay cua chonve.vn
                item.CustomerId   = _workContext.CurrentCustomer.Id;
                item.SessionId    = Session["DAT_MUA_VE_XE_ID"].ToString();
                item.GiaVeHienTai = nguonvexe.GiaVeHienTai;
                if (_phoiveService.DatVe(item))
                {
                    var model = nguonvexe.ToModel(_priceFormatter);
                    model.phoives = _phoiveService.GetPhoiVeDatChoBySession(Session["DAT_MUA_VE_XE_ID"]);
                    bool kq       = _phoiveService.GetPhoiVeByNguonVe(item.NguonVeXeId.GetValueOrDefault(0), item.SessionId, item.CustomerId, item.NgayDi);
                    var  nguonves = new List <NguonVeXeModel>();
                    if (kq)
                    {
                        foreach (var pv in model.phoives)
                        {
                            var result = new NguonVeXeModel();
                            if (string.IsNullOrEmpty(result.KyHieuGhe))
                            {
                                result.KyHieuGhe = pv.sodoghexequytac.Val;
                            }
                            else
                            {
                                result.KyHieuGhe += "," + pv.sodoghexequytac.Val;
                            }
                            result.TongTien += pv.GiaVeHienTai;
                            nguonves.Add(result);
                        }
                    }
                    return(Json(nguonves.ToList(), JsonRequestBehavior.AllowGet));
                }
            }
            return(Json("ERROR", JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public static NguonVeXeModel ToModel(this NguonVeXe e, IPriceFormatter priceFormatter)
        {
            var m = new NguonVeXeModel();

            m.Id       = e.Id;
            m.ParentId = e.ParentId;
            //nhaxe info
            m.NhaXeInfo          = new NguonVeXeModel.NhaXeBasicModel();
            m.NhaXeInfo.Id       = e.NhaXeId;
            m.NhaXeInfo.TenNhaXe = e.TenNhaXe;

            m.DiemDonId       = e.DiemDonId;
            m.DiemDenId       = e.DiemDenId;
            m.LichTrinhId     = e.LichTrinhId;
            m.TimeCloseOnline = e.TimeCloseOnline;
            m.TimeOpenOnline  = e.TimeOpenOnline;
            m.ThoiGianDi      = e.ThoiGianDi;
            m.ThoiGianDen     = e.ThoiGianDen;
            m.GiaVeMoi        = e.ProductInfo.Price;
            m.GiaVeMoiText    = m.GiaVeMoi.ToTien(priceFormatter);
            m.GiaVeCu         = e.ProductInfo.OldPrice;
            m.GiaVeCuText     = m.GiaVeCu.ToTien(priceFormatter);

            m.LoaiXeId   = e.LoaiXeId;
            m.TenDiemDon = e.TenDiemDon;
            m.TenDiemDen = e.TenDiemDen;
            m.TenLoaiXe  = e.TenLoaiXe;
            m.HienThi    = e.HienThi;
            m.ToWeb      = e.ToWeb;
            return(m);
        }