コード例 #1
0
        public BusMessageModel CancelOnlineIssues(string pnrcode)
        {
            BusMessageModel _msg = new BusMessageModel();

            try
            {
                using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required))
                {
                    //remove status from local database

                    var OnlineBusPnr = _ent.Bus_PNRs.FirstOrDefault(x => x.PNRNo == pnrcode);
                    if (OnlineBusPnr == null)
                    {
                        _msg.ActionMessage = "Cancellation Failed !!!!";
                        _msg.ErrSource     = "Data";
                        _msg.MsgNumber     = 1001;
                        _msg.MsgType       = 3;
                        _msg.MsgStatus     = true;
                        return(_msg);
                    }
                    BusApi.BusApiClient       _api = new BusApi.BusApiClient();
                    BusApi.IssueCancelRequest _req = new BusApi.IssueCancelRequest()
                    {
                        Auth           = BusGeneralProvider.AAuth,
                        Remarks        = "Issue Cancelled.",
                        PNRCode        = pnrcode,
                        PassengerId    = null,
                        IsSingleCancel = false
                    };

                    var _spiRes = _api.CancelIssued(_req);

                    if (_spiRes.Message.Number == 0)
                    {
                        OnlineBusPnr.TicketStatusId = 12;
                        _ent.ApplyCurrentValues(OnlineBusPnr.EntityKey.EntitySetName, OnlineBusPnr);
                        // change status of bus_passengers table
                        if (OnlineBusPnr.Bus_Passengers != null)
                        {
                            foreach (var itm in OnlineBusPnr.Bus_Passengers)
                            {
                                itm.TicketStatusId = 12;
                                _ent.ApplyCurrentValues(itm.EntityKey.EntitySetName, itm);
                            }
                        }
                        _ent.Bus_CancelTickets(OnlineBusPnr.BusPNRId, 0, 0, false, ATLTravelPortal.Repository.GeneralRepository.LoggedUserId(), 0);
                        _ent.SaveChanges();
                        ts.Complete(); _msg.ActionMessage = "Cancellation success !! PNR (" + pnrcode + ")";
                        _msg.ErrSource = "Data";
                        _msg.MsgNumber = 1001;
                        _msg.MsgType   = 0;
                        _msg.MsgStatus = true;
                        return(_msg);
                    }
                    else
                    {
                        _msg.ActionMessage = "Cancellation Failed !!!!";
                        _msg.ErrSource     = "Data";
                        _msg.MsgNumber     = 1001;
                        _msg.MsgType       = 3;
                        _msg.MsgStatus     = true;
                        return(_msg);
                    }
                }
            }
            catch
            {
                _msg.ActionMessage = "Cancellation Failed !!!!";
                _msg.ErrSource     = "Data";
                _msg.MsgNumber     = 1001;
                _msg.MsgType       = 3;
                _msg.MsgStatus     = true;
                return(_msg);
            }
        }