Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我需要锁定用户以最多生成两个订单(表单),第二个订单没有锁定在ASP MVC 3上#_C#_Session_Asp.net Mvc 2_Controller - Fatal编程技术网

C# 我需要锁定用户以最多生成两个订单(表单),第二个订单没有锁定在ASP MVC 3上#

C# 我需要锁定用户以最多生成两个订单(表单),第二个订单没有锁定在ASP MVC 3上#,c#,session,asp.net-mvc-2,controller,C#,Session,Asp.net Mvc 2,Controller,感谢阅读我的帖子,我从昨天开始尝试使用此代码锁定函数“secundario”,并始终提供相同的信息,直到我合计或取消该订单 使用“索引”功能可以正常工作,但不使用“secundario”功能 如果您希望查看完整的代码,可以参考我昨天提出的这个问题-> 提前感谢您,我们将非常感谢您的帮助只要这段被剪掉的代码不会为我们编译,如果您能用英语重新编写它会有很大帮助:)而且,即使不了解代码的用途,代码也不是最佳的-首先,您从上下文向pedido_2加载值,然后你从会话中赋值-从数据库加载的第一点是什么?@

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

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

如果您希望查看完整的代码,可以参考我昨天提出的这个问题->


提前感谢您,我们将非常感谢您的帮助

只要这段被剪掉的代码不会为我们编译,如果您能用英语重新编写它会有很大帮助:)而且,即使不了解代码的用途,代码也不是最佳的-首先,您从上下文向pedido_2加载值,然后你从会话中赋值-从数据库加载的第一点是什么?@Giedrius试图避免第三个顺序而不完成前两个,这不起作用,我正在尝试任何方法,这将是一个“因为”
[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
            }

        }