private async void RunePageItem_Apply(Json.Value value) { try { Json.Value currentPageJson = await Wrapper.GetCurrentRunePageAsync(); int order = 0; if (currentPageJson != null) { ulong selectedId = currentPageJson["id"]; if (currentPageJson["isDeletable"]) { await Wrapper.DeleteRunePageAsync(selectedId); } } value["order"] = order; if (!await Wrapper.AddRunePageAsync(value)) { Json.Value pages = await Wrapper.GetRunePagesAsync(); foreach (Json.Value pageJson in pages) { if (pageJson["isDeletable"]) { value["order"] = pageJson["order"]; await Wrapper.DeleteRunePageAsync(pageJson["id"]); await Wrapper.AddRunePageAsync(value); break; } } } } catch (RequestWrapper.NoClientException) { MessagePopup messagePopup = new MessagePopup("Service currently unavailable, try again?"); messagePopup.Decided += delegate(bool result) { if (result) { RunePageItem_Apply(value); } MainViewGrid.Children.Remove(messagePopup); }; MainViewGrid.Children.Add(messagePopup); } }