Example #1
0
 public static void Init(MainViewModel mainViewModel, HomeViewModel homeViewModel,
                         LoginViewModel loginViewModel, RegisterViewModel registerViewModel, SettingViewModel settingViewModel,
                         GalleryViewModel galleryViewModel, TaskManagerViewModel taskManagerViewModel, ManagerPassViewModel managerPassViewModel)
 {
     instance = new ViewModelContainer(mainViewModel, homeViewModel, loginViewModel, registerViewModel, settingViewModel,
                                       galleryViewModel, taskManagerViewModel, managerPassViewModel);
 }
        //dependency injection container
        protected override void OnStartup(StartupEventArgs e)
        {
            // dependenies
            FrameSourceService frameSourceService = new FrameSourceService();
            InvokerService     invokerService     = new InvokerService();
            AuthService        authService        = new AuthService();

            // viewModels
            MainViewModel        mainViewModel        = new MainViewModel(frameSourceService, invokerService);
            HomeViewModel        homeViewModel        = new HomeViewModel(frameSourceService, invokerService);
            LoginViewModel       loginViewModel       = new LoginViewModel(frameSourceService, invokerService, authService);
            RegisterViewModel    registerViewModel    = new RegisterViewModel(frameSourceService, invokerService, authService);
            SettingViewModel     settingViewModel     = new SettingViewModel(frameSourceService, invokerService, authService);
            GalleryViewModel     galleryViewModel     = new GalleryViewModel(frameSourceService, invokerService, authService);
            TaskManagerViewModel taskManagerViewModel = new TaskManagerViewModel(frameSourceService, invokerService, authService);
            ManagerPassViewModel managerPassViewModel = new ManagerPassViewModel(frameSourceService, invokerService, authService);

            // singleton
            ViewModelContainer.Init(mainViewModel, homeViewModel, loginViewModel, registerViewModel,
                                    settingViewModel, galleryViewModel, taskManagerViewModel, managerPassViewModel);

            invokerService.Invoke <MainViewModel>(new InitializationViewModel());

            base.OnStartup(e);
        }
Example #3
0
 private ViewModelContainer(MainViewModel mainViewModel, HomeViewModel homeViewModel,
                            LoginViewModel loginViewModel, RegisterViewModel registerViewModel, SettingViewModel settingViewModel,
                            GalleryViewModel galleryViewModel, TaskManagerViewModel taskManagerViewModel, ManagerPassViewModel managerPassViewModel)
 {
     this.mainViewModel        = mainViewModel;
     this.homeViewModel        = homeViewModel;
     this.loginViewModel       = loginViewModel;
     this.registerViewModel    = registerViewModel;
     this.settingViewModel     = settingViewModel;
     this.galleryViewModel     = galleryViewModel;
     this.taskManagerViewModel = taskManagerViewModel;
     this.managerPassViewModel = managerPassViewModel;
 }
        /* Here Is where Most of the action happens. We make three requests to get all task, user, and assignment
         * Data. If the request fails we return an error message else we create an viewmodel to put all the data in
         * so the view can use it. This makes it easy to pass all the different dtos to the view together. */
        public async Task <ActionResult> Index()
        {
            TaskManagerViewModel model = new TaskManagerViewModel();

            var client = TaskManagerHttpClient.GetClient();

            /* Get all assignments and store in viewmodel */
            HttpResponseMessage response = await client.GetAsync("api/assignments");

            if (response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                model.Assignmentlist = JsonConvert.DeserializeObject <IEnumerable <AssignmentDto> >(content);
            }
            else
            {
                return(Content("Could not retrieve the information."));
            }

            /* Get all tasks and store in viewmodel */
            response = await client.GetAsync("api/tasks");

            if (response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                model.Tasklist = JsonConvert.DeserializeObject <IEnumerable <TaskDto> >(content);
            }
            else
            {
                return(Content("Could not retrieve the information."));
            }

            /* Get all users and store in viewmodel */
            response = await client.GetAsync("api/users");

            if (response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                model.Userlist = JsonConvert.DeserializeObject <IEnumerable <UserDto> >(content);
            }
            else
            {
                return(Content("Could not retrieve the information."));
            }

            /* Finally return the view if successful */
            return(View(model));
        }
Example #5
0
 public RefreshList(TaskManagerViewModel taskManagerViewModel)
 {
     _taskManagerViewModel = taskManagerViewModel;
 }
 public TaskManagerView()
 {
     InitializeComponent();
     DataContext = new TaskManagerViewModel();
 }
Example #7
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new TaskManagerViewModel();
     InitializeApplication();
 }
 public TaskManagerView(TaskManagerViewModel viewModel)
 {
     InitializeComponent();
     ViewModel   = viewModel;
     DataContext = ViewModel;
 }
Example #9
0
        public TaskManager()
        {
            InitializeComponent();

            BindingContext = viewModel = new TaskManagerViewModel();
        }