Example #1
0
        private async Task GetBuildings(bool forceCloud = false)
        {
            using (var dlg = this.Dialogs.Loading("Progress (No Cancel)"))
            {
                Buildings.Clear();

                try
                {
                    var result = await _buildingsService.GetAllBuildings(EstateId, forceCloud);

                    if (!result.Success)
                    {
                        Dialogs.Toast(result.Message);
                        return;
                    }

                    var buildings = result.ResultObject as IEnumerable <BuildingRow>;

                    if (buildings != null && buildings.Any())
                    {
                        Buildings.AddRange(buildings);
                    }
                }
                catch (ServiceAuthenticationException e)
                {
                    var result = await TryToLogin();

                    if (!result)
                    {
                        await NavigationService.NavigateToAsync <LoginViewModel>();
                    }
                    else
                    {
                        await GetBuildings(forceCloud);
                    }
                }
                catch (Exception e)
                {
                    await ShowErrorAlert(e.Message);
                }
            }
        }