public ActionResult DatVe(string codename, int ChuyenDiId, string SessionId, int GiaTien, int isThanhToan, string TenKhach, string DienThoai, string TenDiemDon, string TenDiemTra, string GhiChu, 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(), SessionId, GiaTien.ToString(), isThanhToan.ToString(), TenKhach, DienThoai, TenDiemDon, TenDiemTra, GhiChu); if (!String.IsNullOrEmpty(_checkauthentication)) { return(ErrorOccured(_checkauthentication)); } var chuyendi = _limousinebanveService.GetChuyenDiById(ChuyenDiId); if (chuyendi == null) { return(ErrorOccured("Chuyến đi không tồn tại")); } //trang thai khong hop le if (chuyendi.trangthai == ENTrangThaiXeXuatBen.KET_THUC || chuyendi.trangthai == ENTrangThaiXeXuatBen.HUY) { return(ErrorOccured("Chuyến đi đã kết thúc hoặc bị hủy")); } //kiem tra xem co ai dat chua var _datveitems = _limousinebanveService.GetDatVeBySession(chuyendi.NhaXeId, chuyendi.Id, SessionId); if (_datveitems.Count == 0) { return(ErrorOccured("Không tìm thấy thông tin đặt chỗ")); } TenKhach = DecodeParameter(TenKhach); DienThoai = DecodeParameter(DienThoai); TenDiemDon = DecodeParameter(TenDiemDon); TenDiemTra = DecodeParameter(TenDiemTra); GhiChu = DecodeParameter(GhiChu); //cap nhat thong tin khach hang var _kh = _limousinebanveService.GetKhachHangByDienThoai(chuyendi.NhaXeId, DienThoai); if (_kh == null) { _kh = new KhachHang(); } _kh.NhaXeId = chuyendi.NhaXeId; _kh.DienThoai = DienThoai; _kh.Ten = TenKhach; _kh.DiaChi = TenDiemDon; if (_kh.Id > 0) { _limousinebanveService.UpdateKhachHang(_kh); } else { _kh = _limousinebanveService.InsertKhachHang(_kh); } foreach (var _datveitem in _datveitems) { _datveitem.DiaChiNha = TenDiemDon; _datveitem.GhiChu = GhiChu; _datveitem.KhachHangId = _kh.Id; _datveitem.isThanhToan = isThanhToan == 1; _datveitem.trangthai = ENTrangThaiDatVe.DA_XEP_CHO; _datveitem.TenDiemDon = TenDiemDon; _datveitem.TenDiemTra = TenDiemTra; _datveitem.GiaTien = Convert.ToDecimal(GiaTien); _limousinebanveService.UpdateDatVe(_datveitem); } var models = _limousinebanveService.GetDatVeBySession(chuyendi.NhaXeId, chuyendi.Id, SessionId).Select(c => { return(c.toModel(_localizationService)); }).ToList(); return(Successful(models)); }