BrickPile.UI.Areas.UI.Controllers.PagesController.Sort C# (CSharp) Method

Sort() public method

Sorts the specified items.
public Sort ( List items ) : void
items List The items.
return void
        public void Sort(List<string> items)
        {
            // replace all underscore with slash
            string[] ids = items.Select(key => key.Replace("_", "/")).ToArray();
            // load all documents
            using (IDocumentSession session = this.documentStore.OpenSession())
            {
                IPage[] documents = session.Load<IPage>(ids.ToArray());

                int order = 1;
                foreach (IPage model in documents)
                {
                    model.Metadata.SortOrder = order++;
                }

                session.SaveChanges();
            }
        }