예제 #1
0
        public Field AddFieldToProject(FieldType type, string content, int projectId)
        {
            Domain.Project.Project project = _projectManager.GetProject(projectId);
            if (project == null)
            {
                throw new ArgumentException("Project not found.", "projectId");
            }

            Field field = new Field()
            {
                Content   = content,
                FieldType = type,
                Project   = project
            };

            return(AddField(field));
        }
예제 #2
0
        public Domain.Project.Project AddProject(string title, DateTime start, DateTime end, int organisationId)
        {
            Domain.Organisation.Organisation org = _organisationManager.GetOrganisation(organisationId);

            if (org == null)
            {
                throw new ArgumentException("Organisation not found.");
            }

            Domain.Project.Project newProject = new Domain.Project.Project()
            {
                Title        = title,
                StartDate    = start,
                EndDate      = end,
                Organisation = org
            };

            return(AddProject(newProject));
        }
예제 #3
0
        public ProjectPhase AddProjectPhase(string title, string description, DateTime start, DateTime end, int projectId)
        {
            Domain.Project.Project project = GetProject(projectId);
            if (project == null)
            {
                throw new ArgumentException("Project not found.");
            }

            ProjectPhase newProjectPhase = new ProjectPhase()
            {
                Title       = title,
                Description = description,
                StartDate   = start,
                EndDate     = end,
                Project     = project
            };

            return(AddProjectPhase(newProjectPhase));
        }
예제 #4
0
        public Field ChangeProjectField(int id, FieldType type, string content, int projectId)
        {
            Field toChange = GetField(id);

            if (toChange != null)
            {
                Domain.Project.Project project = _projectManager.GetProject(projectId);
                if (project == null)
                {
                    throw new ArgumentException("Project not found.", "projectId");
                }

                toChange.FieldType = type;
                toChange.Content   = content;
                toChange.Project   = project;

                Validate(toChange);
                return(_fieldRepository.UpdateField(toChange));
            }

            throw new ArgumentException("Field not found.", "id");
        }
예제 #5
0
        public Domain.Project.Project ChangeProject(int id, string title, DateTime start, DateTime end, int organisationId)
        {
            Domain.Organisation.Organisation org = _organisationManager.GetOrganisation(organisationId);

            if (org == null)
            {
                throw new ArgumentException("Organisation not found.", "organisationId");
            }

            Domain.Project.Project p = _projectRepository.ReadProject(id);
            if (p != null)
            {
                p.Title        = title;
                p.StartDate    = start;
                p.EndDate      = end;
                p.Organisation = org;

                Validate(p);
                return(_projectRepository.UpdateProject(p));
            }

            throw new ArgumentException("Project not found.", "id");
        }
예제 #6
0
        public ProjectPhase ChangeProjectPhase(int id, string title, string description, DateTime start, DateTime end, int projectId)
        {
            ProjectPhase toChange = GetProjectPhase(id);

            if (toChange != null)
            {
                Domain.Project.Project project = GetProject(projectId);
                if (project == null)
                {
                    throw new ArgumentException("Project not found.", "projectId");
                }

                toChange.Title       = title;
                toChange.Description = description;
                toChange.StartDate   = start;
                toChange.EndDate     = end;
                toChange.Project     = project;

                Validate(toChange);
                return(_projectPhaseRepository.UpdateProjectPhase(toChange));
            }

            throw new ArgumentException("Phase not found.", "id");
        }
예제 #7
0
 private Domain.Project.Project AddProject(Domain.Project.Project p)
 {
     Validate(p);
     return(_projectRepository.CreateProject(p));
 }
예제 #8
0
 /**
  * Helper method to validate the object we want to persist against the validation annotations.
  * Will throw a ValidationException upon failing.
  */
 private void Validate(Domain.Project.Project project)
 {
     Validator.ValidateObject(project, new ValidationContext(project), true);
 }