public async Task <object> SendService(IBaseViewModel model = null)
        {
            var projetos = await ProjetoService.GetAsync();

            System.Console.WriteLine(projetos.FirstOrDefault()?.Nome);
            return(Injector.Mapper.Map <IEnumerable <ProjetoViewModelGet> >(projetos));
        }
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            var entidade = base.Injector.Mapper.Map <Projeto>((ProjetoViewModelAdd)model);
            await ProjetoService.AddAsync(entidade);

            return(Injector.Notificador.IsValido());
        }
Beispiel #3
0
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            var variaveisCadastradas = await Service.GetWithIncludesAsync();

            return(Injector.Mapper.Map <IEnumerable <VariavelViewModelGet> >(variaveisCadastradas
                                                                             .Where(x => x.IdProjeto == IdProjetoSelecionado)));
        }
Beispiel #4
0
        public static bool IsActive(this IBaseViewModel viewModel, string path)
        {
            var pathList = new List <string>();

            if (!path.StartsWith("/"))
            {
                pathList.Add($"/{path}");
            }

            if (path.StartsWith("/"))
            {
                pathList.Add(path.Substring(1));
            }

            if (!path.EndsWith("/"))
            {
                pathList.Add($"{path}/");
            }

            if (path.EndsWith("/"))
            {
                pathList.Add(path.Substring(0, path.Length - 1));
            }

            pathList.Add(path);

            return(pathList.Any(x => x.Equals(viewModel.Path)));
        }
Beispiel #5
0
        public bool RemoveTabChildFromMainView(IBaseViewModel childViewModel)
        {
            var mainPage = CurrentApplication.MainPage as TabbedPage;

            if (mainPage == null)
            {
                if (CurrentApplication.MainPage is NavigationPage navPageWrapper)
                {
                    mainPage = navPageWrapper.CurrentPage as TabbedPage;
                }
            }

            if (mainPage == null)
            {
                throw new Exception("The current page is either null or not a tabbed page cannot inspect children");
            }

            var childPage = mainPage.Children.FirstOrDefault(_ => (IBaseViewModel)_.BindingContext == childViewModel);

            if (childPage != null)
            {
                mainPage.Children.Remove(childPage);
            }

            return(true);
        }
Beispiel #6
0
        private void OnSelectedMenuItem()
        {
            if (SelectedMenuItem == MenuResources.CallRegistry)
            {
                if (CallRegistryViewModel == null)
                {
                    CallRegistryViewModel = new CallRegistryViewModel(this.Messenger, this.UserLogin)
                    {
                        ParentViewModel = this
                    }
                }
                ;

                DetailSectionViewModel = CallRegistryViewModel;
                return;
            }

            if (SelectedMenuItem == MenuResources.Reminders)
            {
                if (ReminderViewModel == null)
                {
                    ReminderViewModel = new ReminderViewModel(this.Messenger, this.UserLogin)
                    {
                        ParentViewModel = this
                    }
                }
                ;

                DetailSectionViewModel = ReminderViewModel;
            }
        }

        #endregion
    }
}
 public void RunBaseViewModelTests(IBaseViewModel sut)
 {
     // Assert
     Assert.False(string.IsNullOrEmpty(sut.Title), "You didn't set a title");
     Assert.False(string.IsNullOrWhiteSpace(sut.Greeting), "You didn't set a greeting");
     Assert.Equal(defaultsFactory.GetFontSize(), sut.FontSize);
 }
Beispiel #8
0
        /// <summary>
        /// Creates the window.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="viewModel">The view model.</param>
        /// <returns>A new instance of T.</returns>
        public T CreateWindow <T>(IBaseViewModel viewModel) where T : IBaseWindow
        {
            var inst = CustomActivator.CreateInstance <T>();

            inst.AttachContext(viewModel);
            return(inst);
        }
Beispiel #9
0
        public TileViewModel(IBaseViewModel baseViewModel, ITicTac ticTac)
        {
            TileClick = new MvxCommand(Increment);

            _baseViewModel = baseViewModel;
            _ticTac        = ticTac;
        }
        public override void OnNavigationCompleted()
        {
            //ResetFilters("");
            ShowMenu = true;

            IBaseViewModel viewModel = null;

            if (StationRepository.IsLiveMatchEnabled)
            {
                LiveBySportChecked = true;
                viewModel          = MyRegionManager.NavigateUsingViewModel <LiveViewModel>(RegionNames.ContentRegion);
                Mediator.SendMessage(true, MsgTag.ClearSelectedSports);
            }
            else if (StationRepository.IsPrematchEnabled)
            {
                TopTournamentsChecked = true;
                viewModel             = MyRegionManager.NavigateUsingViewModel <TopTournamentsViewModel>(RegionNames.ContentRegion);
            }
            else if (StationRepository.AllowVfl || StationRepository.AllowVhc)
            {
                viewModel = MyRegionManager.NavigateUsingViewModel <EntertainmentViewModel>(RegionNames.ContentRegion);
            }
            else
            {
                viewModel = MyRegionManager.NavigateUsingViewModel <NoContentViewModel>(RegionNames.ContentRegion);
            }
            if (viewModel != null)
            {
                HidePleaseWait = viewModel.IsReady;
            }

            base.OnNavigationCompleted();
        }
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            var modelCast = (ContaOperacoesViewModel)model;
            await ContaService.RealizarOperacao(modelCast.Operacao, modelCast.IdConta, modelCast.Valor, modelCast.IdContaDestino);

            return(Injector.Notificador.IsValido());
        }
Beispiel #12
0
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            var regrasCadastradas = await Service.GetAsync();

            regrasCadastradas = regrasCadastradas.Where(x => x.IdProjeto == IdProjetoSelecionado);
            return(regrasCadastradas.Count());
        }
        public override void AttachContext(IBaseViewModel viewModel)
        {
            this.ViewModel = viewModel;
            this.ViewModel.Init();

            this.DataContext = this.ViewModel;
        }
Beispiel #14
0
        private void OnSuccessfulHealthCheck(OnSuccessfulHealthCheck onSuccessfulHealthCheck)
        {
            switch (this._loginViewModel.LoginUsingExisting())
            {
            case LoginResult.LoginFailed:
                DispatcherHelper.CheckBeginInvokeOnUI((Action)(() =>
                {
                    this.StateViewModel.UpdateActiveView(ViewState.Login);
                    this.CurrentViewModel = (IBaseViewModel)this._loginViewModel;
                }));
                this._loginViewModel.SetupFailingLogin();
                break;

            case LoginResult.InvalidBoardingPass:
                this._messenger.Send <OnStartHealthCheck>(new OnStartHealthCheck());
                DispatcherHelper.CheckBeginInvokeOnUI((Action)(() =>
                {
                    this.StateViewModel.UpdateActiveView(ViewState.HealthCheck);
                    this.CurrentViewModel = (IBaseViewModel)this._healthCheckViewModel;
                }));
                break;

            case LoginResult.LoginSuccessful:
                this._loginViewModel.UpdateState();
                break;

            case LoginResult.NoLoginFound:
                DispatcherHelper.CheckBeginInvokeOnUI((Action)(() =>
                {
                    this.StateViewModel.UpdateActiveView(ViewState.Login);
                    this.CurrentViewModel = (IBaseViewModel)this._loginViewModel;
                }));
                break;
            }
        }
Beispiel #15
0
        protected void NavigateTo(IBaseViewModel viewModel)
        {
            var loadableViewModel = viewModel as ILoadableViewModel;

            _requestNavigationSubject.OnNext(viewModel);
            loadableViewModel?.LoadCommand.ExecuteIfCan();
        }
Beispiel #16
0
        private void ShowViewController(MvxViewModelRequest request)
        {
            MenuNavigationController.HideMenu();

            IBaseViewModel viewModel = null;

            viewModel = request is MvxViewModelInstanceRequest instanceRequest ?
                        (IBaseViewModel)instanceRequest.ViewModelInstance
                            :
                        (IBaseViewModel)Mvx.Resolve <IMvxViewModelLoader>().LoadViewModel(request, null);

            var view = this.CreateViewControllerFor(request);

            view.ViewModel = viewModel;

            var viewController = view as UIViewController;

            var navigationType = viewModel?.VmNavigationType;

            if (navigationType == null || _navigationInProgress)
            {
                return;
            }

            _navigationInProgress = true;

            if (navigationType == NavigationType.ClearAndPush || navigationType == NavigationType.DoubleClearAndPush)
            {
                if (PushRootController(viewController, navigationType == NavigationType.DoubleClearAndPush))
                {
                    SetNavBarButtons(viewController, viewModel?.Title, true);
                }
            }
            else if (navigationType == NavigationType.Push || navigationType == NavigationType.DoublePush)
            {
                var controller = MenuNavigationController.TopNavigationController.PresentedViewController != null?
                                 GetLastPresentedController(MenuNavigationController.TopNavigationController.PresentedViewController) :
                                     MenuNavigationController.TopNavigationController;

                if (controller is UINavigationController navigationController)
                {
                    navigationController.PushViewController(viewController, true);

                    SetNavBarButtons(viewController, viewModel?.Title);
                }
                else if (controller != null)
                {
                    SetupPresentationOptionsAndPresent(viewController, controller);
                }
            }
            else if (navigationType == NavigationType.PresentModal)
            {
                PresentModalViCo(viewController);

                SetNavBarButtons(viewController, viewModel?.Title, true, true);
            }

            _navigationInProgress = false;
        }
Beispiel #17
0
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            var modelCast = (VariavelViewModelAdd)model;
            var entidade  = base.Injector.Mapper.Map <Variavel>(modelCast);
            await Service.AddAsync(entidade);

            return(Injector.Notificador.IsValido());
        }
Beispiel #18
0
        protected void SubscribeToastDialog(IBaseViewModel viewModel)
        {
            viewModel.ToastRequestLiveData.Observe(LifecycleManager, OnToast,
                                                   e => Log.Error("BaseActivity", "error observing ToastRequestLiveData", e));

            viewModel.AlertRequestLiveData.Observe(LifecycleManager, OnDialog,
                                                   e => Log.Error("BaseActivity", "error observing AlertRequestLiveData", e));
        }
Beispiel #19
0
 /// <summary>
 ///     Sets the extended entity
 /// </summary>
 public void SetBaseViewModel(IBaseViewModel baseViewModel)
 {
     if (baseViewModel == null)
     {
         throw new ArgumentNullException("baseViewModel");
     }
     Model = (TModel)baseViewModel;
 }
 private void OnCalculateCohens()
 {
     var result = _cohensCalculator.CalculateEffectSize();
     var resultVM = new ResultVM(result);
     resultVM.CloseCommand = CloseCommand;
     resultVM.SaveCommand = new RelayCommand(p => OnSaveResult(result));
     Content = resultVM;
 }
Beispiel #21
0
        public static IWindow GetWindow(IBaseViewModel view, string type)
        {
            if (view.Windows == null)
            {
                throw new ExceptionApp("Please add view in collection");
            }

            return(view.Windows.FirstOrDefault(x => x.GetType().Name == type));
        }
        /// <summary>
        /// Produces a dictionary of key-value pairs based on the metadata of a <see cref="BaseViewModel"/>.
        /// </summary>
        /// <param name="vm">ViewModel for which to extract metadata from May not be null.</param>
        /// <returns>Dictionnary of key-value pairs based on the metadata of the given <see cref="vm"/>'s type.</returns>
        public IDictionary <string, object> ToDictionary(IBaseViewModel vm)
        {
            if (vm == null)
            {
                throw new ArgumentNullException(nameof(vm));
            }

            return(vm.ToDictionary());
        }
 public void RegisterView(string p_viewModelKey, IBaseViewModel p_viewModel)
 {
     if (!(p_viewModel is BaseViewModel))
     {
         Exception exception = (Exception) new InvalidOperationException(string.Format("register viewModel is not from the right type"));
         throw exception;
     }
     this.m_viewViewModelMapping[p_viewModelKey] = p_viewModel;
 }
Beispiel #24
0
        void NewMenuItem(object menu)
        {
            IBaseViewModel viewModel = GetCurSubModuleVM();

            if (viewModel == null)
            {
                return;
            }
        }
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            var modelCast = (RegraViewModelAdd)model;
            var entidade  = base.Injector.Mapper.Map <Regra>(modelCast);

            entidade.IdProjeto = IdProjetoSelecionado;
            await Service.AddAsync(entidade);

            return(Injector.Notificador.IsValido());
        }
Beispiel #26
0
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            if (!ValidarId(((AlunoAddViewModel)model).IdCurso, "Necessário selecionar um curso."))
            {
                return(false);
            }
            await AlunoService.AddAsync(Injector.Mapper.Map <Aluno>(model));

            return(Injector.Notificador.IsValido());
        }
Beispiel #27
0
        public static void GoPage(this IBaseViewModel @this, string page)
        {
            if (page.IsNullOrWhiteSpace())
            {
                return;
            }
            var pageRoot = App.Instance.NameSpacePage() + "." + page;

            @this.GoPage(Type.GetType(pageRoot));
        }
Beispiel #28
0
        public static void BindViewModel(this IBasePage page, IBaseViewModel viewModel)
        {
            page.BindingContext = viewModel;
            page.SetBinding <IBaseViewModel>(Page.IsBusyProperty, "IsBusy");
            page.SetBinding <IBaseViewModel>(Page.TitleProperty, "Title");
            page.SetBinding <IBaseViewModel>(Page.IconProperty, "Icon");

            page.Appearing    += (sender, args) => viewModel.OnAppearing();
            page.Disappearing += (sender, args) => viewModel.OnDisappearing();
        }
Beispiel #29
0
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            if (!ValidarId(((ClienteGetViewModel)model).Id, "Necessário selecionar o cliente."))
            {
                return(false);
            }
            await ClienteService.UpdateAsync(Injector.Mapper.Map <Cliente>(model));

            return(Injector.Notificador.IsValido());
        }
 public ViewToViewModel(UserControl control, IBaseViewModel type, MyContentRegion region, params object[] args)
 {
     View      = control;
     ViewModel = type;
     Region    = region;
     if (args != null)
     {
         Args = args;
     }
 }
Beispiel #31
0
        public async Task <object> SendService(IBaseViewModel model = null)
        {
            if (!ValidarId(((DisciplinaGetViewModel)model).IdCurso, "Necessário selecionar um curso."))
            {
                return(false);
            }
            await DisciplinaService.UpdateAsync(Injector.Mapper.Map <Disciplina>(model));

            return(Injector.Notificador.IsValido());
        }
        private void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel, UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

//            if (toViewController is SettingsViewController)
//            {
//                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(CodeFramework.iOS.Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
//                toViewDismissCommand.Subscribe(__ => toViewController.DismissViewController(true, null));
//                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
//            }
            if (toViewController is AccountsView)
            {
                var rootNav = (UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController;
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
                toViewDismissCommand.Subscribe(_ => rootNav.DismissViewController(true, null));
                rootNav.PresentViewController(new UINavigationController(toViewController), true, null);
            }
//            else if (fromViewController is RepositoriesViewController)
//            {
//                fromViewController.NavigationController.PresentViewController(toViewController, true, null);
//            }
            else if (toViewController is MenuView)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController);
                var slideout = new SlideoutNavigationController();
                slideout.MenuViewController = new MenuNavigationController(toViewController, slideout);
                UIView.Transition(nav.View, 0.1, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                    () => nav.PushViewController(slideout, false), null);
            }
            else if (toViewController is NewAccountView && fromViewController is StartupView)
            {
                toViewDismissCommand.Subscribe(_ => toViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (fromViewController is MenuView)
            {
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
            else if (toViewController is LanguagesView && fromViewController is RepositoriesTrendingView)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(_ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
        private static void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel,
            UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

            if (toViewController is LoginViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is MainViewController)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.GetWindow().RootViewController);
                UIView.Transition(nav.View, 0.6f,
                    UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                    () => nav.PushViewController(toViewController, false), null);
            }
            else if (toViewController is AddInterestViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is StumbleViewController || toViewController is RepositoryViewController ||
                     toViewController is StumbledRepositoryViewController || toViewController is SettingsViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is LanguagesViewController && fromViewController is TrendingViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else if (toViewController is PurchaseProViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(toViewController, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(
                    _ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
Beispiel #34
0
 protected void NavigateTo(IBaseViewModel viewModel)
 {
     _requestNavigationSubject.OnNext(viewModel);
 }
Beispiel #35
0
 protected void NavigateTo(IBaseViewModel viewModel)
 {
     var loadableViewModel = viewModel as ILoadableViewModel;
     loadableViewModel?.LoadCommand.ExecuteIfCan();
     _requestNavigationSubject.OnNext(viewModel);
 }