コード例 #1
0
        /*
         * CRUD
         */
        public void Register(Freight freight)
        {
            List <Freight> list;

            if (_cookie.isExisting(Key))
            {
                list = Consult();
                var freightLocalized = list.SingleOrDefault(i => i.CEP == freight.CEP);
                if (freightLocalized == null)
                {
                    list.Add(freight);
                }
                else
                {
                    freightLocalized.ShoppingCartCode = freight.ShoppingCartCode;
                    freightLocalized.ListValues       = freight.ListValues;
                }
            }
            else
            {
                list = new List <Freight>();
                list.Add(freight);
            }

            Save(list);
        }
コード例 #2
0
        /*
         * CRUD
         */
        public void Register(ProductItem item)
        {
            List <ProductItem> list;

            if (_cookie.isExisting(Key))
            {
                list = Consult();
                var itemLocalized = list.SingleOrDefault(i => i.Id == item.Id);
                if (itemLocalized == null)
                {
                    list.Add(item);
                }
                else
                {
                    itemLocalized.AmountProductsCart = itemLocalized.AmountProductsCart + 1;
                }
            }
            else
            {
                list = new List <ProductItem>();
                list.Add(item);
            }

            Save(list);
        }