Beispiel #1
0
        //Index
        public ActionResult Index(IndexM model)
        {
            // Page and items per page numbers validation.
            if (model.Page <= 0)
            {
                model.Page = 1;
            }

            if (model.ItemsPerPage <= 0)
            {
                model.ItemsPerPage = 2;
            }

            ProjectsRepo projectRepo = new ProjectsRepo();

            // Saving the filter for shown projects.
            Expression <Func <Project, bool> > filter =
                p => ((String.IsNullOrEmpty(model.Name)) ||
                      (p.Name.Contains(model.Name))) &&
                ((String.IsNullOrEmpty(model.Description)) ||
                 (p.Description.Contains(model.Description))) &&
                ((String.IsNullOrEmpty(model.Client)) ||
                 (p.Client.Contains(model.Client)));

            // Saving the filtered projects to the model.
            model.Items = projectRepo.GetAll(filter,
                                             model.Page, model.ItemsPerPage);

            // Saving the pages count to the model.
            model.PagesCount = (int)Math.Ceiling(projectRepo.Count() / (double)(model.ItemsPerPage));

            return(View(model));
        }
Beispiel #2
0
        //Delete
        public ActionResult Delete(int id)
        {
            ProjectsRepo projectsRepo = new ProjectsRepo();

            Project item = projectsRepo.GetById(id);

            projectsRepo.Delete(item);

            return(RedirectToAction("Index", "Projects"));
        }
Beispiel #3
0
        private TreeNode CreateSubtree(ProjectNode projectNode)
        {
            var result = _views.GetProjectView(projectNode).CreateTreeNode();

            foreach (var moduleNode in ProjectsRepo.GetProjectModules(projectNode))
            {
                result.Nodes.Add(CreateSubtree(moduleNode));
            }
            return(result);
        }
Beispiel #4
0
        private void AdvancedEditorToolStripMenuItemClick(object sender, EventArgs e)
        {
            var proj = ProjectsRepo.FindFirstProject(_currentProject);

            Debug.Assert(proj == _currentProject, "Duplicate projects are found out");
            using (PomAdvancedEditor form = new PomAdvancedEditor(CurrentProjectView, ProjectsRepo))
            {
                form.ShowDialog();
            }
            RefreshPropertyGrid();
        }
Beispiel #5
0
        private void EditAsTextToolStripMenuItemClick(object sender, EventArgs e)
        {
            var proj = ProjectsRepo.FindFirstProject(_currentProject);

            Debug.Assert(proj == _currentProject, "Duplicate projects are found out");
            using (PomTextEditorForm form = new PomTextEditorForm((Project)proj))
            {
                form.ShowDialog();
            }
            RefreshPropertyGrid();
        }
Beispiel #6
0
 private void SaveTree(object sender, EventArgs e)
 {
     try
     {
         ProjectsRepo.SaveChangedProjects();
         CleanErrorListAfterSaveTree();
     }
     catch (Exception ex)
     {
         ShowError(ex.ToString(), ErrorsResources.ErrorSavingProjects);
     }
 }
Beispiel #7
0
        private void PropagateVersionOfAllSelectedNodes(object sender, EventArgs e)
        {
            _listPoms.BeginUpdate();
            _treePoms.BeginUpdate();

            foreach (var prjView in _views.AllViews.Where(v => v.Checked))
            {
                ProjectsRepo.PropagateVersionToAllUsages(prjView.ProjectNode);
            }

            _listPoms.EndUpdate();
            _treePoms.EndUpdate();

            UpdateAllProjectViews();
        }
Beispiel #8
0
        public ActionResult Edit(int?id)
        {
            ProjectsRepo repo = new ProjectsRepo();

            // If id is null, a new project is created.
            // Otherwise the project is extracted from the repo.
            Project item = id == null ?
                           new Project() :
                           repo.GetById(id.Value);

            // Extraction of the project data from the database.
            EditM model = new EditM
            {
                Id          = item.Id,
                Name        = item.Name,
                Description = item.Description,
                Client      = item.Client
            };

            return(View(model));
        }
Beispiel #9
0
        private void PopulateTree()
        {
            var rootNodes = ProjectsRepo != null?ProjectsRepo.GetRootProjects().ToArray() : new ProjectNode[]
            {
            };

            _treePoms.BeginUpdate();
            _treePoms.Nodes.Clear();

            foreach (var projectNode in rootNodes)
            {
                _treePoms.Nodes.Add(CreateSubtree(projectNode));
            }

            _treePoms.EndUpdate();

            if (_treePoms.Nodes.Count != 0)
            {
                _treePoms.SelectedNode = _treePoms.Nodes[0];
            }
        }
Beispiel #10
0
        private List <ContextAction> GetActions()
        {
            List <ContextAction> actionsList = new List <ContextAction>();
            ContextAction        action      = new ContextAction
            {
                IsApplicable    = p => true,
                DelegatedAction = source =>
                {
                    var proj = ProjectsRepo.FindFirstProject(source);
                    using (PomTextEditorForm form = new PomTextEditorForm((Project)proj))
                    {
                        form.ShowDialog();
                    }
                    RefreshPropertyGrid();
                },
                Title = "Edit as text",
            };

            actionsList.Add(action);
            action = new ContextAction
            {
                IsApplicable    = p => true,
                DelegatedAction = source =>
                {
                    var proj = ProjectsRepo.FindFirstProject(source);
                    using (PomAdvancedEditor form = new PomAdvancedEditor(CurrentProjectView, ProjectsRepo))
                    {
                        form.ShowDialog();
                    }
                    RefreshPropertyGrid();
                },
                Title = "Advanced editor",
            };
            actionsList.Add(action);

            return(actionsList);

            // REVIEW: add cascade switch to snapshot for release projects
        }
Beispiel #11
0
        public ActionResult Edit(EditM model)
        {
            // Model validation.
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Extraction of the inputted project data.
            Project item = new Project
            {
                Id          = model.Id,
                Name        = model.Name,
                Description = model.Description,
                Client      = model.Client
            };

            // Saving (inserting/updating) the project in the database.
            ProjectsRepo projectsRepo = new ProjectsRepo();

            projectsRepo.Save(item);

            return(RedirectToAction("Index", "Projects"));
        }
Beispiel #12
0
 private void PropagateVersionToSubtree(object sender, EventArgs e)
 {
     ProjectsRepo.PropagateVersionToSubtree(_currentProjectNode);
     UpdateAllProjectViews();
 }