private async Task SetCurrentItem(int id) { try { if (IsBusy) { return; } IsBusy = true; await Task.Delay(300); var rest = await PermohonanService.GetPermohonanById(id); if (rest != null) { CurrentItem = rest; } RefreshCommand.Execute(null); } catch (Exception ex) { Helper.ShowMessageError(ex.Message); } finally { IsBusy = false; } }
private async void LoadAsync() { try { await Task.Delay(300); if (IsBusy) { return; } IsBusy = true; if (lastPermohonan == null) { lastPermohonan = await PermohonanService.GetLastPermohonan(); CurrentItem = lastPermohonan; } if (CurrentItem != null) { CurrentItem = await PermohonanService.GetPermohonanById(CurrentItem.Id); var layanan = await LayananServices.GetItemAsync(CurrentItem.IdLayanan.ToString()); if (layanan != null) { StepBar.Steps = 0; StepBar.Children.Clear(); StepBar.StepSelected = 0; StepBar.Steps = layanan.Tahapans.Count(); NextTahapan = null; if (CurrentItem.NextTahapan != null) { NextTahapan = CurrentItem.NextTahapan; } ShowSertifikat = false; if (CurrentItem.Tahapans != null && layanan.Tahapans.Count == CurrentItem.Tahapans.Count) { NextTahapan = new tahapan { Nama = "Tidak Ada", Keterangan = "Proses Telah Selesai" }; ShowSertifikat = true; StepBar.Complete(); } if (CurrentItem.CurrentTahapan != null && layanan.Tahapans.Count > CurrentItem.Tahapans.Count) { var c = layanan.Tahapans.Where(O => O.Id == CurrentItem.CurrentTahapan.Id).FirstOrDefault(); if (c != null) { var index = layanan.Tahapans.IndexOf(c); StepBar.StepSelected = index + 1; } } } } var result = await PermohonanService.GetPermohonans(); Permohonans.Clear(); if (result != null) { foreach (var item in result) { Permohonans.Add(item); } } var message = await InboxServices.GetItemsAsync(CurrentItem.Id); LastMessage = null; if (message != null && message.Count() > 0) { LastMessage = message.FirstOrDefault(); } } catch (Exception ex) { Helper.ShowMessageError(ex.Message); } finally { IsBusy = false; } }