borepin/Borepin/Borepin/PageModel/StartUpDistributorPageModel.cs
TheJoKlLa 7b0cf64d0e Revert "Refactoring"
This reverts commit 832f54a7d9360cd25400e3424f6faf147eaaf9c5.
2021-09-20 18:40:39 +02:00

83 lines
2.4 KiB
C#

using Borepin.Base;
using Borepin.Model;
using Borepin.Service.Connections;
using Prism.Commands;
using Prism.Navigation;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Borepin.PageModel
{
public class StartUpDistributorPageModel : PageModelBase
{
#region Private Properties
private readonly IConnectionService _ConnectionService;
#endregion
#region Constructors
public StartUpDistributorPageModel(INavigationService navigationService, IConnectionService connectionService) : base(navigationService)
{
_ConnectionService = connectionService;
DistributePageCommand = new DelegateCommand<string>(DistributePageCommandExecuted);
DistributePageCommand.Execute(null);
}
#endregion
#region LoadData
public override Task LoadData()
{
return Task.CompletedTask;
}
#endregion
#region Command
private ICommand _DistributePageCommand;
public ICommand DistributePageCommand
{
get => _DistributePageCommand;
set => SetProperty(ref _DistributePageCommand, value);
}
private async void DistributePageCommandExecuted(string view)
{
List<Connection> connection_list = await _ConnectionService.GetConnectionList();
if (connection_list.Count == 0)
{
INavigationResult result = await _NavigationService.NavigateAsync("MainPage/NavigationPage/SetUpProcess_WelcomePage");
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
}
else
{
INavigationResult result = await _NavigationService.NavigateAsync("MainPage/NavigationPage/ServerListPage");
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
}
}
#endregion
#region Properties
#endregion
#region INavigationAware
public override void OnNavigatedFrom(INavigationParameters parameters)
{
}
public override void OnNavigatedTo(INavigationParameters parameters)
{
}
#endregion
}
}