Ejemplo n.º 1
0
        public ActionResult LenXe(int NhaXeId, int CustomerId, int XeXuatBenId, int SoDoGheXeQuyTacId, int GiaTien, string DiemLen, string DiemXuong, string apiToken)
        {
            //kiem tra xac thuc
            string _checkauthentication = isAuthentication(NhaXeId, CustomerId, apiToken, XeXuatBenId);

            if (!String.IsNullOrEmpty(_checkauthentication))
            {
                return(ErrorOccured(_checkauthentication));
            }


            var sodo = _xeinfoService.GetSoDoGheXeQuyTacById(SoDoGheXeQuyTacId);

            if (sodo == null)
            {
                return(ErrorOccured("Dữ liệu không hợp lệ"));
            }

            var phoive = _phoiveService.GetPhoiVe(xexuatben.NguonVeId, sodo, xexuatben.NgayDi, true);

            phoive.GiaVeHienTai = Convert.ToDecimal(GiaTien);
            phoive.ViTriLenXe   = DiemLen;
            phoive.ViTriXuongXe = DiemXuong;

            phoive.NguoiDatVeId = currentNhanVien.Id;
            phoive.CustomerId   = CommonHelper.KhachVangLaiId;//khach vang lai
            if (_phoiveService.DatVe(phoive, ENTrangThaiPhoiVe.DaGiaoHang))
            {
                return(SuccessfulSimple(phoive.Id.ToString()));
            }
            return(ErrorOccured("Không đặt được ở vị trí này"));
        }
Ejemplo n.º 2
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));
        }