public List <ScriptItem> GetScriptItems(ScriptItemSelector scriptorderitem)
        {
            string[] Items = System.Text.RegularExpressions.Regex.Split(scriptorderitem.ItemList, ",");

            List <ScriptItem> scriptItems = new List <ScriptItem>();

            API.ItemController itemC = new API.ItemController();

            foreach (string item in Items)
            {
                string[] itemparts = item.Split(new char[] { '\\' });
                switch (itemparts.Length)
                {
                case 1:      //Category Selected
                    scriptItems.AddRange(itemC.GetActiveScriptItems(itemparts[0]));
                    break;

                case 2:
                    scriptItems.AddRange(itemC.GetActiveScriptItems(itemparts[0], itemparts[1]));
                    break;

                case 3:        //Item Selected
                    string[] itempieces = System.Text.RegularExpressions.Regex.Split(itemparts[2], "::");

                    if (itemC.GetActiveScriptItem(itemparts[0], itemparts[1], itempieces[0]) != null)
                    {
                        scriptItems.Add(itemC.GetActiveScriptItem(itemparts[0], itemparts[1], itempieces[0]));
                    }

                    break;

                default:
                    break;
                }
            }

            return(scriptItems);
        }
Exemplo n.º 2
0
        public static bool AddUpdateOrderItem(ItemOrdered Item, HttpSessionStateBase Session)
        {
            List <ItemOrdered> Items = (List <ItemOrdered>)Session["ItemsOrdered"];

            int foundindex   = -1;
            int currentcount = 0;

            if (Items != null)
            {
                foreach (ItemOrdered IO2 in Items)
                {
                    if (Item.ItemCode == IO2.ItemCode)
                    {
                        foundindex = currentcount;
                        break;
                    }
                    currentcount++;
                }
            }
            else
            {
                Items = new List <ItemOrdered>();
            }

            if (foundindex >= 0)
            {
                ItemOrdered IOS = Items[foundindex];
                IOS.ItemQuantity = Item.ItemQuantity;

                Items.RemoveAt(foundindex);

                if (IOS.ItemQuantity > 0)
                {
                    Items.Add(IOS);

                    if (IOS.setKey)
                    {
                        List <string> KeyList = Regex.Split(IOS.SetKeys, ",").ToList();
                        SetItemKeys(Session, KeyList, "I");
                    }
                }
                StoreItemsOrdered(Session, Items);

                //Session["ItemsOrdered"] = Items;

                return(true);
            }

            try
            {
                if (Item.ItemQuantity == 0)
                {
                    return(true);
                }

                ScreenViewer.API.ItemController IC = new API.ItemController();
                var             actionResult       = IC.GetScriptItemByCode(Item.ItemCode);
                var             response           = actionResult as OkNegotiatedContentResult <Data.ScriptItem>;
                Data.ScriptItem SI = response.Content;

                ItemOrdered newitem = new ItemOrdered();

                newitem.ItemCode     = SI.ItemCode;
                newitem.Category     = SI.ItemCategory;
                newitem.SubCategory  = SI.ItemSubCategory;
                newitem.ItemDesc     = SI.ItemDesc;
                newitem.ItemName     = SI.ItemName;
                newitem.ItemPrice    = (decimal)SI.ItemPrice;
                newitem.ItemQuantity = Item.ItemQuantity;
                newitem.ItemShipping = (decimal)SI.ItemShippingPrice;
                newitem.setKey       = Item.setKey;
                //newitem.SetKeys = SI.ItemSetKeys; ??
                newitem.oiOwner = Item.oiOwner;
                Items.Add(newitem);

                StoreItemsOrdered(Session, Items);
                return(true);
            }
            catch
            {
                return(false);
            }
        }