Esempio n. 1
0
        /// <summary>
        /// Lay thong ti chuyen di hien tai theo bien so xe
        /// </summary>
        /// <param name="CustomerId"></param>
        /// <param name="NhaXeId"></param>
        /// <param name="BienSoXe"></param>
        /// <param name="apiToken"></param>
        /// <returns></returns>
        public ActionResult GetChuyenDiHienTai(int NhaXeId, int CustomerId, int XeId, string apiToken)
        {
            //kiem tra xac thuc
            string _checkauthentication = isAuthentication(NhaXeId, CustomerId, apiToken);

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

            //lay thong tin xe van chuyen tu bien so xe
            var xevanchuyen = _xeinfoService.GetXeInfoById(XeId);

            if (xevanchuyen == null)
            {
                return(ErrorOccured("Xe không tồn tại"));
            }

            var chuyendis = _nhaxeService.GetHistoryXeXuatBenByXeVanChuyen(xevanchuyen.Id);

            if (chuyendis.Count == 0)
            {
                return(ErrorOccured("Không có chuyến đi nào tại thời điểm này"));
            }

            //Lấy thông tin cac chuyen di
            var chuyendijson = chuyendis.Select(c => new
            {
                Id          = c.Id,
                NgayDi      = c.NgayDi.toStringDate(),
                GioXuatBen  = c.NguonVeInfo.LichTrinhInfo.ThoiGianDi.ToString("HH:mm"),
                LaiXe       = c.ThongTinLaiPhuXe(0, true),
                ThongTin    = c.NguonVeInfo.GetHanhTrinh(),
                SoHangGhe   = xevanchuyen.loaixe.sodoghe.SoHang,
                SoCotGhe    = xevanchuyen.loaixe.sodoghe.SoCot,
                SoTang      = (int)xevanchuyen.loaixe.KieuXe,
                TrangThaiId = c.TrangThaiId,
                HanhTrinhId = c.NguonVeInfo.LichTrinhInfo.HanhTrinhId
            }).ToList();

            return(Successful(chuyendijson));
        }