private async void RunePageItem_Apply(Json.Value value) { if (await ValidateRequestWrapperAsync()) { Json.Value currentPageJson = await RequestWrapper.GetCurrentRunePageAsync(); int order = 0; if (currentPageJson != null) { ulong selectedId = currentPageJson["id"]; if (currentPageJson["isDeletable"]) { await RequestWrapper.DeleteRunePageAsync(selectedId); } } value["order"] = order; if (!await RequestWrapper.AddRunePageAsync(value)) { Json.Value pages = await RequestWrapper.GetRunePages(); foreach (Json.Value pageJson in pages) { if (pageJson["isDeletable"]) { value["order"] = pageJson["order"]; await RequestWrapper.DeleteRunePageAsync(pageJson["id"]); await RequestWrapper.AddRunePageAsync(value); break; } } } } else { 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); } }