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)); }
public void DeleteComment(CommentModel model, Guid organizationId) { OrganizationModel org = LoadRecordById <OrganizationModel>(_organizationCollection, organizationId); org.GetProjectByIdTree(model.ParentProjectIdTreePath).Comments.Remove(model); UpsertRecord(_organizationCollection, organizationId, org); }
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); }
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); }
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); }
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); }
// 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)); }
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); }