public ActionResult ItemSearch(string order)
 {
     if (HttpContext.User.Identity.IsAuthenticated == false)
     {
         FormsAuthentication.RedirectToLoginPage();
     }
     // Если нет в сессии значения - то инициализация
     if ((Session["ismodel"] == null) || (Session["ismodel"].ToString() == ""))
     {
         Session["err"] = "";
         ismodel.OnInit();
         ismodel.ResetSelectedItem();
         SaveState(ismodel);
         if ((order != null) && (order != ""))
         {
             ismodel.order = int.Parse(order);
         }
     }
     else
     {
         ismodel = RestoreState();
     }
     WriteView();
     List<Items> tmpview = ReadList(ismodel.sortmode, ismodel.SubstringFind);
     if (Session["err"].ToString() != "")
     {
         return RedirectToAction("Errored", "ItemSearch");
     }
     return View(tmpview);
 }
        public ActionResult ItemSearch(string ddl1, string SubstringFind, string button, string selecteditem, string quantity, string ddl2)
        {
            ismodel = RestoreState();
            switch (button)
            {
                case " Search ":
                    {
                        if (SubstringFind == "")
                        {
                            ismodel.SetFilterOption(ddl1, "");
                        }
                        else
                        {
                            ismodel.SetFilterOption(ddl1, SubstringFind);
                        }
                        break;
                    }
                case "   Add  ":
                    {
                        ismodel.ResetSelectedItem();
                        int i = int.Parse(selecteditem);
                        Items tmp = new Items();
                        tmp = ReadList(ismodel.sortmode, ismodel.SubstringFind).ElementAt<Items>(i);
                        if (Session["err"] != "")
                        {
                            return RedirectToAction("Errored", "ItemSearch");
                        }
                        if (i >= 0)
                        {
                            ismodel.SelectedItem = tmp.ItemID;
                            ismodel.CopyItem(tmp);
                        }
                        break;
                    }
                case "  Done  ":
                    {
                        if (ismodel.SelectedItem == -1)
                        {
                            break;
                        }
                        int qu;
                        ismodel.Dimension = ddl2;
                        ItemsOrder rw = new ItemsOrder();
                        if (int.TryParse(quantity, out qu))
                        {
                            ismodel.Quantity = qu;
                            ismodel.order = 123;
                            rw = ismodel.WriteToOrder();
                            OutRecord(rw);
                            if (Session["err"] != "")
                            {
                                return RedirectToAction("Errored", "ItemSearch");
                            }
                            else
                            {
                                Session["ismodel"] = "";
                                return RedirectToAction("~/CustomerOrdering/OrderList.cshtml");
                            }
                        }
                        else
                        {
                            ismodel.Quantity = 1;
                        }

                        break;
                    }
                case "  Close ":
                    {
                        Session["ismodel"] = "";
                        return RedirectToAction("~/CustomerOrdering/OrderList.cshtml");
                    }

            }
            WriteView();
            SaveState(ismodel);
            List<Items> tmpview = ReadList(ismodel.sortmode, ismodel.SubstringFind);
            if (Session["err"] != "")
            {
                return RedirectToAction("Errored", "ItemSearch");
            }
            return View(tmpview);
        }
 public void SaveState(ISModelState tmp)
 {
     Session.Add("isdata", tmp);
 }
 public ISModelState RestoreState()
 {
     ISModelState tmp = new ISModelState();
     tmp = (ISModelState)Session["isdata"];
     return tmp;
 }