예제 #1
0
        public int GetIdeationScore(int ideationId)
        {
            Domain.Ideation.Ideation ideation = GetIdeation(ideationId);
            if (ideation != null)
            {
                return(ideation.GetScore());
            }

            throw new ArgumentException("Ideation not found.");
        }
예제 #2
0
        public void AddVoteToIdeation(Vote vote, int ideationId)
        {
            Domain.Ideation.Ideation ideation = GetIdeation(ideationId);
            if (ideation == null)
            {
                throw new ArgumentException("Ideation not found.");
            }

            vote.Ideation = ideation;
            ideation.Votes.Add(vote);
            _ideationRepository.UpdateIdeation(ideation);
        }
예제 #3
0
        public Domain.Ideation.Ideation ChangeIdeationState(int id, bool newState)
        {
            Domain.Ideation.Ideation toChange = GetIdeation(id);
            if (toChange != null)
            {
                toChange.IsOpen = newState;

                Validate(toChange);
                return(_ideationRepository.UpdateIdeation(toChange));
            }

            throw new ArgumentException("Ideation not found.", "id");
        }
예제 #4
0
        public Domain.Ideation.Ideation AddIdeation(string title, int projectPhaseId)
        {
            ProjectPhase phase = _projectManager.GetProjectPhase(projectPhaseId);

            if (phase == null)
            {
                throw new ArgumentException("Project phase not found.");
            }

            Domain.Ideation.Ideation ideation = new Domain.Ideation.Ideation()
            {
                Title        = title,
                ProjectPhase = phase
            };

            return(AddIdeation(ideation));
        }
예제 #5
0
        public Field AddFieldToIdeation(FieldType type, string content, int ideationId)
        {
            Domain.Ideation.Ideation ideation = GetIdeation(ideationId);
            if (ideation == null)
            {
                throw new ArgumentException("Ideation not found.", "ideationId");
            }

            Field field = new Field()
            {
                Content   = content,
                FieldType = type,
                Ideation  = ideation
            };

            return(AddField(field));
        }
예제 #6
0
        public Domain.Ideation.Ideation ChangeIdeation(int id, string title, int projectPhaseId)
        {
            Domain.Ideation.Ideation toChange = GetIdeation(id);
            if (toChange != null)
            {
                ProjectPhase phase = _projectManager.GetProjectPhase(projectPhaseId);
                if (phase == null)
                {
                    throw new ArgumentException("Project phase not found", "projectPhaseId");
                }

                toChange.Title        = title;
                toChange.ProjectPhase = phase;

                Validate(toChange);
                return(_ideationRepository.UpdateIdeation(toChange));
            }

            throw new ArgumentException("Ideation not found.", "id");
        }
예제 #7
0
        public Idea ChangeIdea(int id, string title, int ideationId)
        {
            Idea toChange = GetIdea(id);

            if (toChange != null)
            {
                Domain.Ideation.Ideation ideation = GetIdeation(ideationId);
                if (ideation == null)
                {
                    throw new ArgumentException("Ideation not found.", "ideationId");
                }

                toChange.Title    = title;
                toChange.Ideation = ideation;

                Validate(toChange);
                return(_ideaRepository.UpdateIdea(toChange));
            }

            throw new ArgumentException("Idea not found.", "id");
        }
예제 #8
0
        public Idea AddIdea(string title, int ideationId)
        {
            Domain.Ideation.Ideation ideation = GetIdeation(ideationId);
            if (ideation == null)
            {
                throw new ArgumentException("Ideation not found.");
            }

            if (!ideation.IsOpen)
            {
                throw new ArgumentException("Ideation is not open for new ideas.");
            }

            Idea idea = new Idea()
            {
                Title    = title,
                Ideation = ideation
            };

            return(AddIdea(idea));
        }
예제 #9
0
        public Field ChangeIdeationField(int id, FieldType type, string content, int ideationId)
        {
            Field toChange = GetField(id);

            if (toChange != null)
            {
                Domain.Ideation.Ideation ideation = GetIdeation(ideationId);
                if (ideation == null)
                {
                    throw new ArgumentException("Ideation not found.", "ideationId");
                }

                toChange.FieldType = type;
                toChange.Content   = content;
                toChange.Ideation  = ideation;

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

            throw new ArgumentException("Field not found.", "id");
        }
예제 #10
0
 private Domain.Ideation.Ideation AddIdeation(Domain.Ideation.Ideation ideation)
 {
     Validate(ideation);
     return(_ideationRepository.CreateIdeation(ideation));
 }
예제 #11
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.Ideation.Ideation ideation)
 {
     Validator.ValidateObject(ideation, new ValidationContext(ideation), true);
 }