Example #1
0
 private async Task SetInitialState(AccountModel user)
 {
     ToolbarInfoCommand = new Command(() => _navigation.Push(_pageFactory.GetPage(PageType.Instruction, false)));
     LogOutCommand      = new Command(async() =>
     {
         if (_userCache.GetLoggedInAccount() == null)
         {
             _navigation.Push(_pageFactory.GetPage(PageType.Landing));
         }
         else
         {
             _userCache.LogOut();
             SetAccountState(null);
             await SetSubState(null);
         }
     });
     SubscriptionCommand = new Command(async() =>
     {
         if (_userCache.GetLoggedInAccount() == null)
         {
             return;
         }
         var valid = await _orderValidator.ValidateOrderRequest(_userCache.GetLoggedInAccount());
         try
         {
             SubscriptionButtonEnabled = false;
             if (SubscriptionUtility.SubscriptionActive(valid.Subscription))
             {
                 _navigation.Push(_pageFactory.GetPage(PageType.ManageSubscription, valid));
             }
             else
             {
                 _navigation.Push(_pageFactory.GetPage(PageType.PurchaseOptions, valid));
             }
         }
         catch (Exception ex)
         {
             _logger.LogError("Failed to handle subscription click command.", ex);
         }
         finally
         {
             SubscriptionButtonEnabled = true;
         }
     });
     FeedbackCommand = new Command(() =>
     {
         try
         {
             FeedbackButtonEnabled = false;
             _navigation.Push(_pageFactory.GetPage(PageType.Feedback, _navigation));
         }
         catch (Exception ex)
         {
             _logger.LogError("Failed to handle feedback click command.", ex);
         }
         finally
         {
             FeedbackButtonEnabled = true;
         }
     });
     SetAccountState(user);
     await SetSubState(user);
 }