protected virtual void SoDoGheXeToSoDoGheXeModel(SoDoGheXe nvfrom, LoaiXeModel.SoDoGheXeModel nvto) { nvto.Id = nvfrom.Id; nvto.TenSoDo = GetLabel(nvfrom.TenSoDo); nvto.UrlImage = nvfrom.TenSoDo; nvto.SoLuongGhe = nvfrom.SoLuongGhe; nvto.KieuXeId = nvfrom.KieuXeId; nvto.SoCot = nvfrom.SoCot; nvto.SoHang = nvfrom.SoHang; }
public ActionResult GetSoDoGheXeInfo(int NguonVeXeId, int ParentId, long NgayDi, int?TangIndex) { int nguonveid = NguonVeXeId; if (ParentId > 0) { nguonveid = ParentId; } //lấy thong tin nguồn xe var nguonvexe = _hanhtrinhService.GetNguonVeXeById(nguonveid); if (nguonvexe == null) { return(new HttpUnauthorizedResult()); } var loaixe = _xeinfoService.GetById(nguonvexe.LoaiXeId); if (loaixe == null) { return(new HttpUnauthorizedResult()); } //var nhaxe = this.getCurrentNhaXe; var sodoghe = _xeinfoService.GetSoDoGheXeById(loaixe.SoDoGheXeID); var modelsodoghe = new LoaiXeModel.SoDoGheXeModel(); modelsodoghe.PhanLoai = ENPhanLoaiPhoiVe.PHOI_VE; SoDoGheXeToSoDoGheXeModel(sodoghe, modelsodoghe); //Lấy thông tin ma tran var sodoghevitris = _xeinfoService.GetAllSoDoGheViTri(sodoghe.Id); var sodoghequytacs = _xeinfoService.GetAllSoDoGheXeQuyTac(loaixe.Id); modelsodoghe.MaTran = new int[modelsodoghe.SoHang, modelsodoghe.SoCot]; modelsodoghe.PhoiVes1 = new LoaiXeModel.PhoiVeAdvanceModel[modelsodoghe.SoHang + 1, modelsodoghe.SoCot + 1]; modelsodoghe.SoTang = 1; if (sodoghe.KieuXe == ENKieuXe.GiuongNam) { modelsodoghe.SoTang = 2; modelsodoghe.PhoiVes2 = new LoaiXeModel.PhoiVeAdvanceModel[modelsodoghe.SoHang + 1, modelsodoghe.SoCot + 1]; } foreach (var s in sodoghevitris) { modelsodoghe.MaTran[s.y, s.x] = 1; } DateTime _ngaydi = new DateTime(NgayDi); if (sodoghequytacs != null && sodoghequytacs.Count > 0) { foreach (var s in sodoghequytacs) { if (s.Tang == 1) { modelsodoghe.PhoiVes1[s.y, s.x] = new LoaiXeModel.PhoiVeAdvanceModel(); modelsodoghe.PhoiVes1[s.y, s.x].KyHieu = s.Val; if (s.y >= 1 && s.x >= 1) { //kiem tra thong tin vi tri phoi ve modelsodoghe.PhoiVes1[s.y, s.x].Info = _phoiveService.GetPhoiVe(nguonveid, s, _ngaydi, true); modelsodoghe.PhoiVes1[s.y, s.x].IsCurrentCustomer = true; if (modelsodoghe.PhoiVes1[s.y, s.x].Info.TrangThai != ENTrangThaiPhoiVe.Huy && modelsodoghe.PhoiVes1[s.y, s.x].Info.TrangThai != ENTrangThaiPhoiVe.ConTrong) { if (modelsodoghe.PhoiVes1[s.y, s.x].Info.CustomerId != _workContext.CurrentCustomer.Id) { modelsodoghe.PhoiVes1[s.y, s.x].IsCurrentCustomer = false; } } } } else { modelsodoghe.PhoiVes2[s.y, s.x] = new LoaiXeModel.PhoiVeAdvanceModel(); modelsodoghe.PhoiVes2[s.y, s.x].KyHieu = s.Val; if (s.y >= 1 && s.x >= 1) { //kiem tra thong tin vi tri phoi ve modelsodoghe.PhoiVes2[s.y, s.x].Info = _phoiveService.GetPhoiVe(nguonveid, s, _ngaydi, true); modelsodoghe.PhoiVes2[s.y, s.x].IsCurrentCustomer = true; if (modelsodoghe.PhoiVes2[s.y, s.x].Info.TrangThai != ENTrangThaiPhoiVe.Huy && modelsodoghe.PhoiVes2[s.y, s.x].Info.TrangThai != ENTrangThaiPhoiVe.ConTrong) { if (modelsodoghe.PhoiVes2[s.y, s.x].Info.CustomerId != _workContext.CurrentCustomer.Id) { modelsodoghe.PhoiVes2[s.y, s.x].IsCurrentCustomer = false; } } } } } } //selected tab SaveSelectedTabIndex(TangIndex); return(PartialView(modelsodoghe)); }
public ActionResult GetSoDoGheXeInfo(int NguonVeXeId, string NgayDi, int?TangIndex) { if (this.CheckNoAccessIntoNhaXe(_workContext, _permissionService, StandardPermissionProvider.CVQLChuyen)) { return(AccessDeniedView()); } //lấy thong tin nguồn xe var nguonvexe = _hanhtrinhService.GetNguonVeXeById(NguonVeXeId); if (nguonvexe == null) { return(AccessDeniedView()); } var loaixe = _xeinfoService.GetById(nguonvexe.LoaiXeId); if (loaixe == null) { return(AccessDeniedView()); } //var nhaxe = this._workContext.CurrentNhaXe; var sodoghe = _xeinfoService.GetSoDoGheXeById(loaixe.SoDoGheXeID); var modelsodoghe = new LoaiXeModel.SoDoGheXeModel(); SoDoGheXeToSoDoGheXeModel(sodoghe, modelsodoghe); //Lấy thông tin ma tran var sodoghevitris = _xeinfoService.GetAllSoDoGheViTri(sodoghe.Id); var sodoghequytacs = _xeinfoService.GetAllSoDoGheXeQuyTac(loaixe.Id); modelsodoghe.MaTran = new int[modelsodoghe.SoHang, modelsodoghe.SoCot]; modelsodoghe.PhoiVes1 = new LoaiXeModel.PhoiVeAdvanceModel[modelsodoghe.SoHang + 1, modelsodoghe.SoCot + 1]; modelsodoghe.SoTang = 1; if (sodoghe.KieuXe == ENKieuXe.GiuongNam) { modelsodoghe.SoTang = 2; modelsodoghe.PhoiVes2 = new LoaiXeModel.PhoiVeAdvanceModel[modelsodoghe.SoHang + 1, modelsodoghe.SoCot + 1]; } foreach (var s in sodoghevitris) { modelsodoghe.MaTran[s.y, s.x] = 1; } DateTime _ngaydi = Convert.ToDateTime(NgayDi); if (sodoghequytacs != null && sodoghequytacs.Count > 0) { foreach (var s in sodoghequytacs) { if (s.Tang == 1) { modelsodoghe.PhoiVes1[s.y, s.x] = new LoaiXeModel.PhoiVeAdvanceModel(); modelsodoghe.PhoiVes1[s.y, s.x].KyHieu = s.Val; if (s.y >= 1 && s.x >= 1) { modelsodoghe.PhoiVes1[s.y, s.x].Info = _phoiveService.GetPhoiVe(NguonVeXeId, s, _ngaydi, true); if (modelsodoghe.PhoiVes1[s.y, s.x].Info.customer != null) { var ViTriGhe = modelsodoghe.PhoiVes1[s.y, s.x]; int idkhachhang = ViTriGhe.Info.customer.Id; if (idkhachhang == CommonHelper.KhachVangLaiId) { var _khachhang = _customerService.GetCustomerById(idkhachhang); ViTriGhe.TenKhachHang = _khachhang.GetFullName(); ViTriGhe.SoDienThoai = ""; } else { var khachhang = _nhaxecustomerService.GetNhaXeCustomerByCustomerId(idkhachhang); if (khachhang != null) { ViTriGhe.TenKhachHang = khachhang.HoTen; ViTriGhe.SoDienThoai = khachhang.DienThoai; } } } } } else { modelsodoghe.PhoiVes2[s.y, s.x] = new LoaiXeModel.PhoiVeAdvanceModel(); modelsodoghe.PhoiVes2[s.y, s.x].KyHieu = s.Val; if (s.y >= 1 && s.x >= 1) { modelsodoghe.PhoiVes2[s.y, s.x].Info = _phoiveService.GetPhoiVe(NguonVeXeId, s, _ngaydi, true); if (modelsodoghe.PhoiVes2[s.y, s.x].Info.customer != null) { var ViTriGhe = modelsodoghe.PhoiVes2[s.y, s.x]; int idkhachhang = ViTriGhe.Info.customer.Id; if (idkhachhang == CommonHelper.KhachVangLaiId) { var _khachhang = _customerService.GetCustomerById(idkhachhang); ViTriGhe.TenKhachHang = _khachhang.GetFullName(); ViTriGhe.SoDienThoai = ""; } else { var khachhang = _nhaxecustomerService.GetNhaXeCustomerByCustomerId(idkhachhang); if (khachhang != null) { ViTriGhe.TenKhachHang = khachhang.HoTen; ViTriGhe.SoDienThoai = khachhang.DienThoai; } } } } } } } //selected tab SaveSelectedTabIndex(TangIndex); return(PartialView(modelsodoghe)); }