Untitled

 avatar
unknown
plain_text
3 years ago
5.7 kB
2
Indexable
        public ActionResult Confirm(string trxId, string err, string suc, string mandat)
        {
            Guid userGuid = (Guid)Membership.GetUser().ProviderUserKey;
            loadBalanceValueViewData(userGuid);
            string error = "";
            bool success = true;
            trx_loanInfo _trx_invoice = null;
            trx_master _trx_master = null;
            CapitalInvestConfirmViewModel _confirmInvoice = new CapitalInvestConfirmViewModel();

            try
            {
                if (_db.trx_masters.Any(t => t.trx_id == trxId && t.id_agent == userGuid))
                {
                    _trx_master = _db.trx_masters.SingleOrDefault(tr => tr.trx_id == trxId && tr.id_agent == userGuid);
                    _trx_invoice = _db.trx_loanInfos.SingleOrDefault(t => t.trx_id == trxId);
                }
            }
            catch { }

            if (_trx_invoice != null)
            {
                _confirmInvoice.serviceName = _trx_master.sherbimi;
                _confirmInvoice.TRXID = trxId;
                _confirmInvoice.Paguesi = string.IsNullOrEmpty(_trx_invoice.payeeFullName) ? _trx_invoice.clientName : _trx_invoice.payeeFullName;
                _confirmInvoice.personalNo = _trx_invoice.clientId;
                _confirmInvoice.LoanRef = _trx_invoice.loanRef;
                
                _confirmInvoice.PaguesiId = _trx_invoice.payerPersonalNumber;
               // _confirmInvoice.contractNo = _trx_invoiceUKF.contractNo;
                _confirmInvoice.serviceName = _trx_invoice.service;
                //_confirmInvoice.invoiceDate = _trx_invoiceUKF.month + " " + _trx_invoiceUKF.year;
                _confirmInvoice.customer = _trx_invoice.clientName;
                _confirmInvoice.Amount = _trx_invoice.totalBalance;
                _confirmInvoice.TotalDue = _trx_invoice.totalBalance;
                _confirmInvoice.personalNo = _trx_invoice.clientId;
                _confirmInvoice.SumToPay = _trx_invoice.amountPaid;
                _confirmInvoice.phoneNumber = _trx_invoice.phoneGivenToEP;
                _confirmInvoice.datelindjePaguesi = _trx_invoice.datelindjePaguesit;
                _confirmInvoice.IDTypePaguesi = _trx_invoice.tipiIDPaguesit;
               
            }
            else
            {
                err = "NOEX";
            }
            if (!string.IsNullOrEmpty(err))
            {
                switch (err)
                {
                    case "NW":
                        success = false;
                        error = "Pagesa NUK mund te konfirmohet! Nuk keni llogari te regjistruar.";
                        break;
                    case "NEB":
                        success = false;
                        error = "Pagesa NUK mund te konfirmohet! Nuk keni GJENDJE TE MJAFTUESHME ne llogari.";
                        break;
                    case "SECON":
                        success = false;
                        error = "Pagesa nuk mund te vazhdoje per shkak te nje problemi nga ana e Capital Invest. Na kontaktoni ne telefon.";
                        break;
                    case "CONFT":
                        success = false;
                        error = "Pagesa nuk u krye me SUKSES (TIMEOUT)! Ju lutem riprovoni te kryeni nga fillimi kete pagese.";
                        break;
                    case "NOEX":
                        success = false;
                        error = "Transaksioni per pagesen e kesaj fature nuk ekziston! Ju lutem provoni perseri!";
                        break;
                    case "PFAIL":
                        success = false;
                        error = "Kryerja e pagaeses deshtoi, ju lutem provoni perseri!";
                        break;
                    case "IE":
                        success = false;
                        error = "Pagesa nuk mund te vazhdoje per shkak te nje problemi te brendshem. Na kontaktoni ne telefon.";
                        break;
                    case "INVPAID":
                        success = false;
                        error = "Kjo fature me kete seri rezulton e paguar!";
                        break;
                    case "INVSTATE":
                        success = false;
                        error = "Transaksioni per pagesen e kesaj fature nuk eshte ne statusin e duhur! Ju lutem provoni perseri!";
                        break;

                }
            }

            ViewData["showCancelButton"] = (_trx_master.status_shitje == 1 && _trx_master.status_rimbushje == 1);
            ViewData["showConfirmButton"] = (_trx_master.status_shitje == 1 && _trx_master.status_rimbushje == 1);
            ViewData["showPrintButton"] = (_trx_master.status_shitje == 2 && _trx_master.status_rimbushje == 2);
            ViewData["showSuccessMessage"] = suc == "success";
            if (!success)
            {
                ModelState.AddModelError("", error);
            }
          

            if (mandat == "true")
            {
                TimeSpan fiveMin = new TimeSpan(0, 5, 0);
                if ((DateTime.Now - _trx_master.krijuar > fiveMin) && _trx_master.status_rimbushje == 2 && _trx_master.status_shitje == 2)
                {

                    return RedirectToAction("Confirm", new
                    {
                        trxId = trxId,
                        suc = "success",
                        mandat = "false"
                    });
                }
            }

            return View(_confirmInvoice);

        }
Editor is loading...