public ActionResult Index(string gTot, string nTransac) { try { TrPaymentMenuViewModel vm = new TrPaymentMenuViewModel(); if (string.IsNullOrEmpty(nTransac)) { ////provisoire //vm.GlobalTotal = "399.97"; //vm.NumTransaction = "11"; //ViewBag.tot = "399.97"; //ViewBag.transac = "11"; //ViewBag.ticket = false; throw new NullReferenceException(); } else { if (string.IsNullOrEmpty(gTot)) { gTot = TransactionBL.FindTotalByTransacId(nTransac); } var listAmounts = PaymentBL.MakeAmountsList(nTransac); if (listAmounts.Count == 0) { vm.GlobalTotal = gTot; ViewBag.tot = gTot; ViewBag.ticket = false; } else { vm.AmountsPaid = listAmounts; decimal result = PaymentBL.AdaptTotalWithPaid(gTot, listAmounts); if (result < 0) { decimal temp = Math.Abs(result); vm.CashReturn = temp.ToString(); ViewBag.cashBack = temp.ToString(); vm.GlobalTotal = "0"; ViewBag.tot = "0"; vm.Ticket = TicketBL.FillTicket(nTransac); ViewBag.ticket = true; } else if (result == 0) { ViewBag.cashBack = "0"; vm.GlobalTotal = "0"; ViewBag.tot = "0"; vm.Ticket = TicketBL.FillTicket(nTransac); ViewBag.ticket = true; } else { vm.GlobalTotal = result.ToString(); ViewBag.tot = result.ToString(); ViewBag.ticket = false; } } vm.NumTransaction = nTransac; ViewBag.transac = nTransac; } vm.MethodsP = PaymentBL.FindMethodsList(); ViewBag.messageCard = ""; return(View(vm)); } catch (NullReferenceException ex) { //to do insert to log file var e1 = ex.GetBaseException(); // --> log var e4 = ex.Message; // --> log var e5 = ex.Source; // --> log var e8 = ex.GetType(); // --> log var e9 = ex.GetType().Name; // --> log ViewBag.Error = "Il n'y a pas de transaction en cours !"; return(View("Error")); } catch (Exception ex) { //to do insert to log file var e1 = ex.GetBaseException(); // --> log var e4 = ex.Message; // --> log var e5 = ex.Source; // --> log var e8 = ex.GetType(); // --> log var e9 = ex.GetType().Name; // --> log return(View("Error")); } }
//[Authorize(Roles = "admin")] //[Authorize(Roles = "manager")] //[Authorize(Roles = "vendor")] public ActionResult Index(string gTot, string nTransac) { try { TrPaymentMenuViewModel vm = new TrPaymentMenuViewModel(); if (string.IsNullOrEmpty(nTransac)) { throw new NullReferenceException(); } else { if (Session["Language"] == null) { Session["Language"] = ConfigurationManager.AppSettings["Language"]; } string language = Session["Language"].ToString(); if (string.IsNullOrEmpty(gTot)) { gTot = TransactionBL.FindTotalByTransacId(nTransac); } var listAmounts = PaymentBL.MakeAmountsList(nTransac); if (listAmounts.Count == 0) { vm.GlobalTotal = gTot; ViewBag.tot = gTot; ViewBag.ticket = false; } else { vm.AmountsPaid = listAmounts; decimal result = PaymentBL.AdaptTotalWithPaid(gTot, listAmounts); if (result < 0) { decimal temp = Math.Abs(result); vm.CashReturn = temp.ToString(); ViewBag.cashBack = temp.ToString(); vm.GlobalTotal = "0"; ViewBag.tot = "0"; //to do --> change init isChange... bool isChange = false; vm.Ticket = TicketBL.FillTicket(nTransac, language, isChange); ViewBag.ticket = true; } else if (result == 0) { ViewBag.cashBack = "0"; vm.GlobalTotal = "0"; ViewBag.tot = "0"; //to do --> change init isChange... bool isChange = false; vm.Ticket = TicketBL.FillTicket(nTransac, language, isChange); ViewBag.ticket = true; } else { vm.GlobalTotal = result.ToString(); ViewBag.tot = result.ToString(); ViewBag.ticket = false; } } vm.NumTransaction = nTransac; ViewBag.transac = nTransac; } vm.MethodsP = PaymentBL.FindMethodsList(); vm.Languages = LanguageBL.FindLanguageListWithoutUniversal(); ViewBag.messageCard = ""; return(View(vm)); } catch (NullReferenceException ex) { //to do insert to log file var e1 = ex.GetBaseException(); // --> log var e4 = ex.Message; // --> log var e5 = ex.Source; // --> log var e8 = ex.GetType(); // --> log var e9 = ex.GetType().Name; // --> log ViewBag.Error = "Il n'y a pas de transaction en cours !"; return(View("Error")); } catch (Exception ex) { //to do insert to log file var e1 = ex.GetBaseException(); // --> log var e4 = ex.Message; // --> log var e5 = ex.Source; // --> log var e8 = ex.GetType(); // --> log var e9 = ex.GetType().Name; // --> log return(View("Error")); } }