Exemple #1
0
        private readonly ITimeAPI timeAPI; // = new TimeAPI();

        #endregion Fields

        #region Constructors

        public TLFacadeAPI(IProjectAPI projectAPI, ITaskAPI taskAPI, ITimeAPI timeAPI, IProfileAPI profileAPI)
        {
            this.projectAPI = projectAPI;
            this.taskAPI = taskAPI;
            this.timeAPI = timeAPI;
            this.profileAPI = profileAPI;
        }
        public AddProjectPageViewModel(IProjectAPI _projectAPI, IAuthenticationHelper _helper, INavigationService _service, ILocationAPI _locationAPI, ISkillAPI _skillAPI, IAttachmentAPI _attachmentAPI)
        {
            projectAPI    = _projectAPI;
            helper        = _helper;
            service       = _service;
            skillAPI      = _skillAPI;
            attachmentAPI = _attachmentAPI;
            locationAPI   = _locationAPI;
            account       = CommonAttributes.account;
            UserName      = account.UserName;

            SignInOutButtonText = account == null ? "Sign In" : "Sign Out";

            //init countries list
            Countries = new ObservableCollection <string>(GetCountryList());

            SignInOutCommand = new RelayCommand(async o =>
            {
                //sign out
                if (account != null)
                {
                    await helper.SignOutAsync(account);
                    account = null;
                    CommonAttributes.account = account;
                    SignInOutButtonText      = "Sign In";
                    service.Navigate(typeof(LogInPage), null);
                }
                else //sign in
                {
                    account = await helper.SignInAsync();
                    if (account != null)
                    {
                        CommonAttributes.account = account;

                        UserName = account.UserName;

                        SignInOutButtonText = "Sign Out";
                    }
                }
            });

            MenuOptions = new HamburgerMenuOptionsFactory(CommonAttributes.account).MenuOptions;
        }
        public SearchPageViewModel(IAuthenticationHelper _helper, IProjectAPI _projectAPI)
        {
            projectAPI = _projectAPI;
            helper     = _helper;
            account    = CommonAttributes.account;
            UserName   = account.UserName;

            SignInOutButtonText = account == null ? "Sign In" : "Sign Out";

            ProjectResults = new ObservableCollection <ProjectViewModel>();
            UserResults    = new ObservableCollection <UserDTO>();

            SignInOutCommand = new RelayCommand(async o =>
            {
                //sign out
                if (account != null)
                {
                    await helper.SignOutAsync(account);
                    account = null;
                    CommonAttributes.account = account;
                    ProjectResults.Clear();
                    SignInOutButtonText = "Sign In";
                }
                else //sign in
                {
                    account = await helper.SignInAsync();
                    if (account != null)
                    {
                        CommonAttributes.account = account;

                        UserName = account.UserName;

                        //Store the stuff in a static class
                        MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions;

                        SignInOutButtonText = "Sign Out";
                    }
                }
            });

            MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions;
        }
        public MainPageViewModel(IAuthenticationHelper _helper, IProjectAPI _projectAPI, INavigationService _service)
        {
            helper     = _helper;
            service    = _service;
            projectAPI = _projectAPI;

            initDummyCategories();

            //pop up the login screen if user is not logged in
            //called only on startup
            SignInCommand = new RelayCommand(async a =>
            {
                if (account == null)
                {
                    SignInOutButtonText = "Sign In";

                    account = await helper.SignInAsync();

                    if (account != null)
                    {
                        CommonAttributes.account = account;

                        UserName = account.UserName;
                        GetRecentProjects();

                        SignInOutButtonText = "Sign Out";

                        MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions;
                    }
                }
                else
                {
                    GetRecentProjects();

                    SignInOutButtonText = "Sign Out";
                }
            });

            SignInOutCommand = new RelayCommand(async o =>
            {
                //sign out
                if (account != null)
                {
                    await helper.SignOutAsync(account);
                    account = null;
                    CommonAttributes.account = account;
                    Content.Clear();
                    SignInOutButtonText = "Sign In";
                    service.Navigate(typeof(LogInPage), null);
                }
                else //sign in
                {
                    account = await helper.SignInAsync();
                    if (account != null)
                    {
                        //initDummyProjects();

                        GetRecentProjects();

                        CommonAttributes.account = account;

                        UserName = account.UserName;

                        //Store the stuff in a static class
                        MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions;

                        SignInOutButtonText = "Sign Out";
                    }
                }
            });

            RepopulateContentCommand = new RelayCommand(async(tabName) =>
            {
                //Populate lists
                switch (tabName)
                {
                case "Recent":
                    GetRecentProjects();
                    break;

                case "Categories":
                    initDummyCategories();
                    break;
                }
            });

            //pop up sign in page on startup
            SignInCommand.Execute(null);

            //Store the stuff in a static class
            MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions;
            CommonAttributes.MenuOptions = MenuOptions;
        }