PageRenderTime 13ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/V2.2/trunk/Quickstarts/UI Composition/ViewDiscovery/Desktop/UIComposition.Modules.Project/Views/ProjectsListView/ProjectsListPresenter.cs

#
C# | 45 lines | 25 code | 4 blank | 16 comment | 2 complexity | 04775420f5eb2dd0395fc19bdd71db4a MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 4//===================================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===================================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===================================================================================
17using UIComposition.Modules.Project.Services;
18
19namespace UIComposition.Modules.Project
20{
21    public class ProjectsListPresenter : IProjectsListPresenter
22    {
23        private readonly IProjectService projectService;
24        readonly ProjectsListPresentationModel model;
25
26        public ProjectsListPresenter(IProjectsListView view, IProjectService projectService)
27        {
28            this.View = view;
29            this.projectService = projectService;
30            this.model = new ProjectsListPresentationModel();
31            this.model.PropertyChanged += this.model_PropertyChanged;
32            view.Model = this.model;
33        }
34
35        void model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
36        {
37            if (e.PropertyName == "EmployeeId")
38            {
39                model.Projects = this.projectService.RetrieveProjects(this.model.EmployeeId);
40            }
41        }
42
43        public IProjectsListView View { get; set; }
44    }
45}