예제 #1
0
        public void GetGetProjectByIdTree_ShouldWork()
        {
            OrganizationModel org = new OrganizationModel();

            org.Projects.Add(new ProjectModel()
            {
                Name = "George"
            });
            org.Projects[0].AddSubProject(new ProjectModel()
            {
                Name = "John"
            });
            ProjectModel p = new ProjectModel()
            {
                Name = "Fred"
            };

            org.Projects[0].SubProjects[0].AddSubProject(p);

            List <Guid> path = new List <Guid>(p.ParentIdTreePath)
            {
                p.Id
            };

            ProjectModel p2 = org.GetProjectByIdTree(path);

            Assert.Equal(p, p2);
            Assert.Equal(org.Projects[0].SubProjects[0], org.GetProjectByIdTree(p.ParentIdTreePath));
        }
예제 #2
0
        public void DeleteComment(CommentModel model, Guid organizationId)
        {
            OrganizationModel org = LoadRecordById <OrganizationModel>(_organizationCollection, organizationId);

            org.GetProjectByIdTree(model.ParentProjectIdTreePath).Comments.Remove(model);
            UpsertRecord(_organizationCollection, organizationId, org);
        }
예제 #3
0
        public void CreateComment(CommentModel model, Guid organizationId)
        {
            OrganizationModel org = LoadRecordById <OrganizationModel>(_organizationCollection, organizationId);

            // this is ok because model.ParentProjectIdTreePath is already filled out.
            org.GetProjectByIdTree(model.ParentProjectIdTreePath).Comments.Add(model);
            UpsertRecord(_organizationCollection, organizationId, org);
        }
예제 #4
0
        public void DeleteProject(ProjectModel model, Guid organizationId)
        {
            OrganizationModel org = LoadRecordById <OrganizationModel>(_organizationCollection, organizationId);

            if (model.ParentIdTreePath.Count > 0)
            {
                org.GetProjectByIdTree(model.ParentIdTreePath).SubProjects.Remove(model);
            }
            else
            {
                org.Projects.Remove(model);
            }
            UpsertRecord(_organizationCollection, organizationId, org);
        }
예제 #5
0
        public void UpdateComment(CommentModel model, Guid organizationId)
        {
            OrganizationModel org    = LoadRecordById <OrganizationModel>(_organizationCollection, organizationId);
            ProjectModel      parent = org.GetProjectByIdTree(model.ParentProjectIdTreePath);

            int i = parent.Comments.FindIndex(c => DateTime.Equals(c.DatePosted, model.DatePosted)); // todo: decide if dateposted is a valid unique id for comments.

            if (i < 0)
            {
                return;
            }

            parent.Comments[i] = model;
            UpsertRecord(_organizationCollection, organizationId, org);
        }
예제 #6
0
        public void CreateProject(ProjectModel model, Guid organizationId)
        {
            OrganizationModel org = LoadRecordById <OrganizationModel>(_organizationCollection, organizationId);

            // this is ok because model.ParentIdTreePath is already filled out.
            if (model.ParentIdTreePath.Count > 0)
            {
                org.GetProjectByIdTree(model.ParentIdTreePath).SubProjects.Add(model);
            }
            else
            {
                org.Projects.Add(model);
            }
            UpsertRecord(_organizationCollection, organizationId, org);
        }
예제 #7
0
        // GET: Project/ProjectHome page, with edit boxes and subproject links
        public IActionResult ProjectHome(List <Guid> projectIdTreePath)
        {
            OrganizationModel org   = this.GetLoggedInUsersOrganization(_db);
            ProjectModel      proj  = org.GetProjectByIdTree(projectIdTreePath);
            ProjectViewModel  projV = new()
            {
                Project = proj
            };
            Dictionary <Guid, UserModel> workers = _db.GetAllOrganizationUsers(org.Id);

            foreach (Guid id in proj.WorkerIds)
            {
                projV.Workers.Add(id, workers[id]);
            }
            return(View(projV));
        }
예제 #8
0
        public void UpdateProject(ProjectModel model, Guid organizationId)
        {
            OrganizationModel org = LoadRecordById <OrganizationModel>(_organizationCollection, organizationId);

            if (model.ParentIdTreePath.Count > 0)
            {
                ProjectModel parent = org.GetProjectByIdTree(model.ParentIdTreePath);

                int i = parent.SubProjects.FindIndex(p => p.Id == model.Id);
                if (i < 0)
                {
                    return;
                }

                parent.SubProjects[i] = model;
            }
            else
            {
                org.Projects.Add(model);
            }
            UpsertRecord(_organizationCollection, organizationId, org);
        }