Exemplo n.º 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var name        = tbProjectName.Text;
            var description = tbProjectDescription.Text;
            var status      = cbProjectStatus.SelectedValue as ProjectStatusProxy;
            var dateStart   = dpProjectDateCreated.SelectedDate;
            var project     = currentProject;

            if (project == null)
            {
                project               = new ProjectProxy();
                project.Name          = name;
                project.Owner         = User.Instance.Account;
                project.Description   = description;
                project.ProjectStatus = status;
                project.DateStart     = dateStart.Value;
                service.CreateProject(User.Instance.Account.Id, project);
            }
            else
            {
                project.Name          = name;
                project.Description   = description;
                project.ProjectStatus = status;
                project.DateStart     = dateStart.Value;

                service.UpdateProject(User.Instance.Account.Id, project);
            }

            DialogResult = true;
        }
Exemplo n.º 2
0
        private bool ShowCreateProject(ViewType typeView, ProjectProxy project)
        {
            var proj = new ProjectWindow(service, project, typeView);

            proj.Owner = this;
            return(proj.ShowDialog().Value);
        }
Exemplo n.º 3
0
 public List <ProjectProxy> GetProjectsByOwnerId(int ownerId)
 {
     using (var db = new DatabaseEntities())
     {
         var projects = db.Projects.Where(p => p.Owner == ownerId).ToList();
         return(ProjectProxy.GetListProjectProxy(projects));
     }
 }
Exemplo n.º 4
0
 public List <ProjectProxy> GetProjectsByStatus(ProjectStatusProxy status)
 {
     using (var db = new DatabaseEntities())
     {
         var projects = db.Projects.Where(p => p.ProjectStatusId == status.Id).ToList();
         return(ProjectProxy.GetListProjectProxy(projects));
     }
 }
Exemplo n.º 5
0
 private void lvPrjProjectList_Selected(object sender, RoutedEventArgs e)
 {
     selectedProject = (lvPrjProjectList.SelectedItem as ProjectProxy);
     if (selectedProject == null)
     {
         return;
     }
     UpdatePrjParticipantList(service.GetAccountListByProjectId(selectedProject.Id));
     UpdatePrjTaskList(service.GetTasksByProjectId(selectedProject.Id));
 }
Exemplo n.º 6
0
 public void UpdateProject(int accountId, ProjectProxy project)
 {
     dataAccess.UpdateProject(project);
     dataAccess.AddHistory(
         new HistoryProxy(
             0,
             DateTime.Now,
             string.Format("User {0} edited project {1}", dataAccess.GetAccountById(accountId).FullName, project.Name)),
         dataAccess.GetAccountListByProjectId(project.Id)
         );
 }
Exemplo n.º 7
0
        private void lvPrjProjectList_Selected(object sender, SelectionChangedEventArgs e)
        {
            selectedProject = lvPrjProjectList.SelectedItem as ProjectProxy;
            btnPrjDeleteProject.IsEnabled = selectedProject != null;
            btnPrjUpdateProject.IsEnabled = selectedProject != null;

            if (selectedProject != null)
            {
                UpdatePrjTaskList(service.GetTasksByProjectId(selectedProject.Id));
                UpdatePrjParticipantList(service.GetAccountListByProjectId(selectedProject.Id));
            }
        }
Exemplo n.º 8
0
        public void GetHashCodeShouldReturnSameValueForIdenticalObject()
        {
            Project p1 = new ProjectProxy();
            p1.Id = 1;

            Project p2 = new ProjectProxy();
            p2.Id = 1;

            int p1Hash = p1.GetHashCode();
            int p2Hash = p2.GetHashCode();
            
            Assert.AreEqual(p1Hash,p2Hash);
        }
Exemplo n.º 9
0
        public ProjectWindow(ServiceClient service, ProjectProxy project, ViewType typeView)
        {
            InitializeComponent();
            this.service        = service;
            this.currentProject = project;

            InitializeProject(typeView);

            btnTaskEdit.IsEnabled          = false;
            btnTaskDelete.IsEnabled        = false;
            btnParticipantDelete.IsEnabled = false;
            btnStatusEdit.IsEnabled        = false;
            btnStatusDelete.IsEnabled      = false;
        }
Exemplo n.º 10
0
 private void UpdateComboBoxStatus(ProjectProxy project)
 {
     Task.Run(() =>
     {
         cbProjectStatus.Dispatcher.Invoke(() =>
         {
             var statusList = service.GetProjectStatusListByProjectId(project.Id);
             cbProjectStatus.ItemsSource = statusList;
             if (project.ProjectStatus != null)
             {
                 cbProjectStatus.SelectedItem = statusList.FirstOrDefault(p => p.Id == project.ProjectStatus.Id);
             }
         });
     });
 }
Exemplo n.º 11
0
        public void ProjectShouldBeEqualToProxy()
        {
            Project project = new Project
            {
                Id = 3,
                Name = "Test"
            };

            Project projectProxy = new ProjectProxy
            {
                Name = "Test",
                Id = 3
            };

            Assert.IsTrue(projectProxy.Equals(project));
        }
Exemplo n.º 12
0
        public void UpdateProject(ProjectProxy project)
        {
            using (var db = new DatabaseEntities())
            {
                var proj = db.Projects.FirstOrDefault(p => p.Id == project.Id);
                if (proj == null)
                {
                    return;
                }
                proj.Name        = project.Name;
                proj.Description = project.Description;
                if (project.ProjectStatus != null)
                {
                    proj.ProjectStatusId = project.ProjectStatus.Id;
                }
                proj.DateStart = project.DateStart;

                db.SaveChanges();
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Called when [opened project].
        /// </summary>
        /// <param name="hierarchy">The hierarchy.</param>
        /// <param name="isNew">if set to <c>true</c> [is new].</param>
        public void OnOpenedProject(IVsHierarchy hierarchy, bool isNew)
        {
            // Visual Studio reports folders as opened projects but without a name
            var project = hierarchy.ToProject();

            if (string.IsNullOrWhiteSpace(project.FullName))
            {
                return;
            }

            var projectProxy = new ProjectProxy(project.Name, project);

            projectProxy.Hierarchy     = hierarchy;
            projectProxy.SolutionProxy = this;
            projectProxy.RelativePath  = project.GetRelativePath(Source);
            projectProxy.Renamed      += ProjectProxy_Renamed;

            _projectCache.Add(projectProxy);
            Target.OnOpenedProject(projectProxy.Name);
        }
Exemplo n.º 14
0
        public ProjectProxy CreateProject(ProjectProxy project)
        {
            using (var db = new DatabaseEntities())
            {
                var proj = new Project()
                {
                    Name        = project.Name,
                    Description = project.Description,
                    DateStart   = project.DateStart
                };
                if (project.ProjectStatus != null)
                {
                    proj.ProjectStatusId = project.ProjectStatus.Id;
                }
                if (project.Owner != null)
                {
                    proj.Owner = project.Owner.Id;
                }

                var p = db.Projects.Add(proj);

                db.SaveChanges();

                db.AccountsProjects.Add(new AccountsProject()
                {
                    Account = project.Owner.Id, Project = p.Id
                });
                var s = db.ProjectStatus.Add(new ProjectStatu()
                {
                    Name = "Added", Project = p.Id
                });
                db.SaveChanges();
                proj.ProjectStatusId = s.Id;
                db.TaskStatus.Add(new TaskStatu()
                {
                    Name = "TODO:", Project = p.Id
                });
                db.SaveChanges();
                return(GetProjectById(p.Id));
            }
        }
Exemplo n.º 15
0
 public CreateStatusWindow(ServiceClient service, ProjectProxy project)
 {
     InitializeComponent();
     this.service        = service;
     this.currentProject = project;
 }
Exemplo n.º 16
0
 public ProjectProxy CreateProject(ProjectProxy project)
 {
     return(projectControl.CreateProject(project));
 }
Exemplo n.º 17
0
 public void UpdateProject(ProjectProxy project)
 {
     projectControl.UpdateProject(project);
 }
Exemplo n.º 18
0
        //###########################################################
        //#################Method with callback######################
        //############################################################
        public ProjectProxy CreateProject(int accountId, ProjectProxy project)
        {
            var proj = dataAccess.CreateProject(project);

            return(proj);
        }