Exemplo n.º 1
0
        public ActionResult GetSoDoGheXe(int NhaXeId, int CustomerId, int XeXuatBenId, string apiToken)
        {
            //kiem tra xac thuc
            string _checkauthentication = isAuthentication(NhaXeId, CustomerId, apiToken, XeXuatBenId);

            if (!String.IsNullOrEmpty(_checkauthentication))
            {
                return(ErrorOccured(_checkauthentication));
            }
            var datves = _limousinebanveService.GetDatVeByChuyenDi(XeXuatBenId);
            //lay thong tin so do ghe xe
            var sodoghequytacs = _xeinfoService.GetAllSoDoGheXeQuyTac(xexuatben.xevanchuyen.LoaiXeId);
            var phoives        = new List <PhoiVeMobileModel>();

            //kiem tra trang thai tung ghe tren so do
            foreach (var sodo in sodoghequytacs)
            {
                var item = new PhoiVeMobileModel();
                //thong tin ghe/vi tri tri
                item.Val  = sodo.Val;
                item.x    = sodo.x;
                item.y    = sodo.y;
                item.Tang = sodo.Tang;
                item.SoDoGheXeQuyTacId = sodo.Id;
                //thong tin trang thai vi tri
                var phoive = datves.Where(c => c.SoDoGheId == sodo.Id).FirstOrDefault();
                if (phoive == null)
                {
                    phoive            = new DatVe();
                    phoive.trangthai  = ENTrangThaiDatVe.CON_TRONG;
                    phoive.ChuyenDiId = xexuatben.Id;
                    phoive.NgayDi     = xexuatben.NgayDi;
                    phoive.GiaTien    = xexuatben.lichtrinh.GiaVeToanTuyen;
                }
                item.Id          = phoive.Id;
                item.TrangThaiId = phoive.TrangThaiId;
                item.ChuyenDiId  = phoive.ChuyenDiId.GetValueOrDefault(0);
                item.NgayDi      = phoive.NgayDi.toStringDate();
                item.GiaVe       = Convert.ToInt32(phoive.GiaTien);
                item.CustomerId  = phoive.KhachHangId.GetValueOrDefault();
                item.MaVe        = phoive.Ma;
                if (phoive.diemdon != null)
                {
                    item.ViTriXuong = phoive.diemdon.TenDiemDon;
                }
                if (phoive.khachhang != null)
                {
                    item.TenKhachHang = phoive.khachhang.Ten;
                    item.SoDienThoai  = phoive.khachhang.DienThoai;
                }
                phoives.Add(item);
            }

            return(Successful(phoives));
        }
Exemplo n.º 2
0
        public ActionResult GetSoDoGheXe(string codename, int ChuyenDiId, string checksum)
        {
            //kiem tra ket noi setting
            string _checkauthentication = isAuthentication(codename);

            if (!String.IsNullOrEmpty(_checkauthentication))
            {
                return(ErrorOccured(_checkauthentication));
            }
            //kiem tra check sum
            _checkauthentication = isRightCheckSum(checksum, codename, ChuyenDiId.ToString());
            if (!String.IsNullOrEmpty(_checkauthentication))
            {
                return(ErrorOccured(_checkauthentication));
            }
            var xexuatben = GetChuyenDiHienTai(ChuyenDiId);

            if (xexuatben == null)
            {
                return(ErrorOccured("Chuyến đi không tồn tại"));
            }
            var datves = _limousinebanveService.GetDatVeByChuyenDi(ChuyenDiId);
            //lay thong tin so do ghe xe
            var sodoghequytacs = _xeinfoService.GetAllSoDoGheXeQuyTac(xexuatben.lichtrinhloaixe.LoaiXeId);
            var phoives        = new List <PhoiVeMobileModel>();

            //kiem tra trang thai tung ghe tren so do
            foreach (var sodo in sodoghequytacs)
            {
                var item = new PhoiVeMobileModel();
                //thong tin ghe/vi tri tri
                item.Val  = sodo.Val;
                item.x    = sodo.x;
                item.y    = sodo.y;
                item.Tang = sodo.Tang;
                item.SoDoGheXeQuyTacId = sodo.Id;
                //thong tin trang thai vi tri
                var phoive = datves.Where(c => c.SoDoGheId == sodo.Id).FirstOrDefault();
                if (phoive == null)
                {
                    phoive            = new DatVe();
                    phoive.trangthai  = ENTrangThaiDatVe.CON_TRONG;
                    phoive.ChuyenDiId = xexuatben.Id;
                    phoive.NgayDi     = xexuatben.NgayDi;
                    phoive.GiaTien    = _limousinebanveService.GetGiaVeTheoSoDoId(xexuatben.HanhTrinhId, xexuatben.lichtrinhloaixe.LoaiXeId, sodo.Id);
                    //lay gia ve theo cau hinh gia ve theo lich trinh
                    if (phoive.GiaTien == decimal.Zero)
                    {
                        phoive.GiaTien = xexuatben.lichtrinhloaixe.GiaVe;
                    }
                }
                item.Id          = phoive.Id;
                item.TrangThaiId = phoive.TrangThaiId;
                item.ChuyenDiId  = phoive.ChuyenDiId.GetValueOrDefault(0);
                item.NgayDi      = phoive.NgayDi.toStringDate();
                item.GiaVe       = Convert.ToInt32(phoive.GiaTien);
                item.CustomerId  = phoive.KhachHangId.GetValueOrDefault();
                item.MaVe        = phoive.Ma;
                item.ViTriLen    = phoive.TenDiemDon;
                item.ViTriXuong  = phoive.TenDiemDon;
                if (phoive.khachhang != null)
                {
                    item.TenKhachHang = phoive.khachhang.Ten;
                    item.SoDienThoai  = phoive.khachhang.DienThoai;
                }
                phoives.Add(item);
            }

            return(Successful(phoives));
        }