public void Put(int id, ReorderItemModel model)
        {
            var item = _items.Where(i => i.ItemId == id).Single();

            var beforeItem = _items.Where(i => i.ItemId == model.BeforeItemId).SingleOrDefault();
            var afterItem  = _items.Where(i => i.ItemId == model.AfterItemId).SingleOrDefault();


            if (afterItem != null &&
                beforeItem != null)
            {
                item.SortOrder = (afterItem.SortOrder + beforeItem.SortOrder) / 2.0f;
            }
            else if (afterItem != null)
            {
                item.SortOrder = afterItem.SortOrder + 1000;
            }
            else if (beforeItem != null)
            {
                item.SortOrder = beforeItem.SortOrder / 2.0f;
                if (item.SortOrder > 1000)
                {
                    item.SortOrder = 1000;
                }
            }

            // Notify about the update
            ItemsHub.UpdateItemSortOrder(id, item.SortOrder);
        }
 public QuestionnaireViewModel(ItemsHub hub, Action <bool> callbackSave)
 {
     this.hub = hub;
     callback = callbackSave;
 }
Esempio n. 3
0
 public ItemsController(ItemsHub hub)
 {
     this.hub = hub;
 }