Example #1
0
        public ActionResult Index(string submitButton, string globalDiscount, TrIndexViewModel vmodel)
        {
            try
            {
                switch (submitButton.ToLower())
                {
                case "payment":
                    return(Payment(globalDiscount, vmodel));

                case "cancel":
                    return(CancelTransac(vmodel));

                case "back":
                    return(TransactionProductBack(vmodel));

                default:
                    ViewBag.ticket = false;
                    return(View(vmodel));
                }
            }
            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"));
            }
        }
Example #2
0
        public ActionResult Index()
        {
            try
            {
                int terminal        = TerminalBL.FindTerminalIdByDate();
                TrIndexViewModel vm = new TrIndexViewModel
                {
                    ////terminal name or id
                    TerminalId = terminal,

                    ////transaction num = id
                    // to do --> provisoire vendorId = 1, shopId = 1, customerId = 1
                    NumTransaction = TransactionBL.InitializeNewTransaction(terminal),

                    // to do --> quid date et heure?
                    DateDay = DateTime.Now.Date.ToString("d"),
                    HourDay = DateTime.Now.ToString("T"),

                    Vendor = "Toto", // --> id = 1
                };
                return(View(vm));
            }
            catch (EntityException 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
                TempData["Error"] = "L'initialisation de la transaction ne s'est pas déroulé correctement, veuillez contacter l'administrateur";
                return(RedirectToAction("Transaction", "Home"));
            }
            catch (InvalidOperationException 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
                TempData["Error"] = "Il manque un fond de caisse pour cette date";
                return(RedirectToAction("Transaction", "Home"));
            }
            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
                TempData["Error"] = "Il y a un soucis avec l'action demandé, veuillez contacter l'administrateur";
                return(RedirectToAction("Transaction", "Home"));
            }
        }
Example #3
0
 private ActionResult CancelTransac(TrIndexViewModel vmodel)
 {
     if (string.IsNullOrEmpty(vmodel.NumTransaction))
     {
         var detailsListTot = TransactionBL.ListDetailsWithTot(vmodel.NumTransaction);
         //Sum subTotItems
         ViewBag.subTot1           = TransactionBL.SumItemsSubTot(detailsListTot);
         vmodel.DetailsListWithTot = detailsListTot;
         return(View("Index", vmodel));
     }
     TransactionBL.CancelTransac(vmodel.NumTransaction);
     return(RedirectToAction("Transaction", "Home"));
 }
Example #4
0
 public ActionResult TransacReturn(TrPaymentMenuViewModel vmodel)
 {
     try
     {
         var detailsListTot  = TransactionBL.ListDetailsWithTot(vmodel.NumTransaction);
         var transac         = TransactionBL.FindTransactionById(vmodel.NumTransaction);
         TrIndexViewModel vm = new TrIndexViewModel
         {
             //vm.TerminalId = terminal;
             NumTransaction = vmodel.NumTransaction,
             TerminalId     = transac.terminalId,
             GlobalTot      = transac.total.ToString(),
             GlobalDiscount = (transac.discountGlobal) * 100,
             // to do --> quid date et heure?
             DateDay = DateTime.Now.Date.ToString("d"),
             HourDay = DateTime.Now.ToString("T"),
             //to do --> ameliorer   Vendor = string  et vendorId = int
             Vendor = (transac.vendorId).ToString(),
             //to do or not--> transac.discountGlobal à afficher
             //to do or not--> with transac.vatId  return appliedVat
             DetailsListWithTot = detailsListTot
         };
         //Sum subTotItems
         ViewBag.subTot1 = TransactionBL.SumItemsSubTot(detailsListTot);
         return(View("Index", vm));
     }
     catch (InvalidOperationException ex)
     {
         //to do insert to log file
         //NumTransaction not valid
         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(RedirectToAction("Index", "Pay", vmodel));
     }
     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"));
     }
 }
Example #5
0
        private ActionResult TransactionProductBack(TrIndexViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                //save part of transaction
                TransactionBL.SaveTransactionProductBack(vmodel.NumTransaction, vmodel.GlobalTot);
                string gTot     = vmodel.GlobalTot;
                string nTransac = vmodel.NumTransaction;
                return(RedirectToAction("ProductBack", "Pay", new { nTransac }));
            }
            var detailsListTot = TransactionBL.ListDetailsWithTot(vmodel.NumTransaction);

            //Sum subTotItems
            ViewBag.subTot1           = TransactionBL.SumItemsSubTot(detailsListTot);
            vmodel.DetailsListWithTot = detailsListTot;
            return(View(vmodel));
        }
Example #6
0
        private ActionResult Payment(string globalDiscount, TrIndexViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                //save part of transaction
                TransactionBL.SaveTransactionBeforePayment(vmodel.NumTransaction, vmodel.GlobalTot, globalDiscount);
                var gTot     = vmodel.GlobalTot;
                var nTransac = vmodel.NumTransaction;
                return(RedirectToAction("Index", "Pay", new { gTot, nTransac }));
            }
            var detailsListTot = TransactionBL.ListDetailsWithTot(vmodel.NumTransaction);

            //Sum subTotItems
            ViewBag.subTot1           = TransactionBL.SumItemsSubTot(detailsListTot);
            vmodel.DetailsListWithTot = detailsListTot;
            return(View(vmodel));
        }
Example #7
0
        public ActionResult Index()
        {
            try
            {
                //récupération du terminal
                int terminal = 0;

                if (Session["sessTerminalId"] != null)
                {
                    //terminal = int.Parse(Session["sessTerminalId"].ToString());
                    terminal = Convert.ToInt32(Session["sessTerminalId"]);
                }
                else
                {
                    terminal = TerminalBL.FindTerminalIdByDate();
                    // tot do --> modifier si plusieur cashday diff terminaux
                }

                ////récupération de la langue
                if (Session["Language"] == null)
                {
                    Session["Language"] = ConfigurationManager.AppSettings["Language"];
                }

                //récupération de l'utilisateur
                string           currentId = User.Identity.GetUserId();
                TrIndexViewModel vm        = new TrIndexViewModel
                {
                    ////terminal name or id
                    TerminalId = terminal,

                    ////transaction num = id
                    // to do --> provisoire shopId = 1, customerId = 1
                    NumTransaction = TransactionBL.InitializeNewTransaction(terminal, currentId),

                    // to do --> quid date et heure?
                    DateDay = DateTime.Now.Date.ToString("d"),
                    HourDay = DateTime.Now.ToString("T")
                };
                return(View(vm));
            }

            catch (EntityException 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
                TempData["Error"] = "L'initialisation de la transaction ne s'est pas déroulé correctement, veuillez contacter l'administrateur";
                return(RedirectToAction("Transaction", "Home"));
            }

            catch (InvalidOperationException ex)
            {
                //Viewbag not work with RedirectToAction --> use TempData
                //ViewBag.Error = "Il manque un fond de caisse pour cette date";
                //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
                TempData["Error"] = "Il manque un fond de caisse pour cette date";
                return(RedirectToAction("Transaction", "Home"));
            }

            catch (Exception ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); //Description error --> log
                //var e2 = ex.GetType(); //InvalidOperationException //DbUpdateException
                //var e3 = ex.InnerException;
                var e4 = ex.Message;        // --> log
                var e5 = ex.Source;         // --> log
                var e8 = ex.GetType();      // --> log
                var e9 = ex.GetType().Name; // --> log

                TempData["Error"] = "Il y a un problème avec l'action demandée, veuillez contacter l'administrateur";
                return(RedirectToAction("Transaction", "Home"));
            }
        }