Ejemplo n.º 1
0
        public static void SetSortOrderByListPosition(List <int> categoryIdsInSortOrder)
        {
            CategoryQuery q = new CategoryQuery();

            q.Where(q.Id.In(categoryIdsInSortOrder.ToArray()));

            CategoryCollection collection = new CategoryCollection();

            if (collection.Load(q))
            {
                for (short i = 0; i < categoryIdsInSortOrder.Count; i++)
                {
                    Category c = collection.FindByPrimaryKey(categoryIdsInSortOrder[i]);
                    if (c != null)
                    {
                        c.SortOrder = i;
                    }
                }
                collection.Save();
            }
        }