public static List<ShoppingCartItem> GetItems(string connectionString, Dictionary<int, int> itemCountPerId)
 {
     List<ShoppingCartItem> result = new List<ShoppingCartItem>();
     using(DbProviderDataContext dbContext = new DbProviderDataContext(connectionString)){
         var xmlNodes = dbContext.cmsContentXmls.Where(item => itemCountPerId.Keys.Contains(item.nodeId)).Select(item => item.xml);
         foreach(var xmlNode in xmlNodes){
             result.Add(GetShoppingCartItemFromXml(xmlNode, itemCountPerId));
         }
     }
     return result;
 }
        //private void AddItemsToSession(int id, int count) {
        //    Dictionary<int, int> shoppingCartItems = new Dictionary<int, int>();
        //    if (Session["ShoppingCartItems"] != null) {
        //        shoppingCartItems = (Dictionary<int, int>)Session["ShoppingCartItems"];
        //    }
        //    if (shoppingCartItems.Any(item => item.Key == id)) {
        //        shoppingCartItems[id] += count;
        //    } else {
        //        shoppingCartItems[id] = count;
        //    }
        //    Session["ShoppingCartItems"] = shoppingCartItems;
        //}
        //private void UpdateCartItems(Dictionary<int, int> items) {
        //    Dictionary<int, int> cartItems = GetItemsFromSession();
        //    foreach (var item in items) {
        //        cartItems[item.Key] = item.Value;
        //    }
        //}
        //private Dictionary<int, int> GetItemsFromSession() {
        //    Dictionary<int, int> sessionShoppingCartItems = new Dictionary<int, int>();
        //    if (Session["ShoppingCartItems"] != null) {
        //        sessionShoppingCartItems = (Dictionary<int, int>)Session["ShoppingCartItems"];
        //    }
        //    return sessionShoppingCartItems;
        //}
        //private void DeleteItemFromSession(int id) {
        //    if (Session["ShoppingCartItems"] != null) {
        //        Dictionary<int, int> shoppingCartItems = (Dictionary<int, int>)Session["ShoppingCartItems"];
        //        if (shoppingCartItems.Any(item => item.Key == id)) {
        //            shoppingCartItems.Remove(id);
        //        }
        //    }
        //}
        private void UpdateBoughtProductsCount(Dictionary<int, int> orderedProducts)
        {
            using (DbProviderDataContext dbContext = new DbProviderDataContext(ConfigurationManager.AppSettings["umbracoDbDSN"])) {
                if (orderedProducts != null) {
                    foreach (var kvp in orderedProducts) {
                        var boughtProduct = dbContext.BoughtProducts.Where(x => x.NodeId == kvp.Key).FirstOrDefault();
                        if (boughtProduct == null) {
                            dbContext.BoughtProducts.InsertOnSubmit(new BoughtProduct { NodeId = kvp.Key, Count = kvp.Value });
                        } else {
                            boughtProduct.Count = boughtProduct.Count + kvp.Value;
                        }
                    }

                    dbContext.SubmitChanges();
                }
            }
        }