0

感谢您阅读我的帖子,我从昨天开始尝试使用此代码锁定功能“secundario”并始终提供相同的信息,直到我总计或取消该订单。

使用“index”功能可以正常工作,但不能使用“secundario”功能

[AuthorizeRoles(Modulo = "4310")]
        public ActionResult Index()
        {
            /* Lot of Code Here */

            var pedido_1 = dc.SAFACTs.FirstOrDefault(b => b.CodUsua == User.Identity.Name && b.SAFACT_01.Estado == "0");

            if (pedido_1 != null)
            {
                Session["pedido1"] = pedido_1;

                /* Lot of Code Here */

            }

            /* If order "pedido1" does not exist, we create a new order */

            return View(pedido_1); //Load the view with the data and here works the lock. View Data with the data of pedido_1 until the user totalize or cancel this order

        }

[AuthorizeRoles(Modulo = "4310")]
        public ActionResult secundario()
        {
            if (Session["pedido1"] != null) //I check if the first order "pedido1" exists, if exists i do the second order
            {
                /* Lot of Code Here */

                var pedido_2 = dc.SAFACTs.Skip(1).Take(1).FirstOrDefault(b => b.CodUsua == User.Identity.Name && b.SAFACT_01.Estado == "0");

                if (Session["pedido2"] != null)
                {
                    pedido_2 = (PRINCIPAL.Areas.VENTAS.Models.SAFACT)Session["pedido2"];
                    //Session["pedido2"] = pedido_2;
                }

                if (pedido_2 != null)
                {
                    /* Lot of Code Here */
                }

                /* If order "pedido2" does not exist, we create a new order */

                return View(pedido_2); /* Load the view with the data and here DOES NOT work the lock and i can make n orders 
                I should View Data with the data of pedido_2 until the user totalize or cancel this order
                */
            }
            else // If first order "pedido1" does not exist i redirect the user to index function
            {
                return RedirectToAction("Index", "PROG_4310"); //Redirect to Index
            }

        }

如果您想查看完整代码,可以参考我昨天做的这个问题 ->链接

提前致谢,任何帮助将不胜感激

4

0 回答 0