public void ErrorCodes_should_be_populated_when_title_is_empty()
        {
            IdeaDataObject idea = new IdeaDataObject();

            validator.IsValid(idea);
            Assert.IsTrue(validator.ErrorCodes.Contains(ErrorCodes.IdeaForm.ERROR_IDEAFORM_TITLE_REQUIRED));
        }
Example #2
0
        public int Update(IdeaDataObject idea)
        {
            if (idea.Id == 0)
            {
                throw new CustomException("Cannot update Idea details.");
            }
            int userId = ideaData.GetCreatorUserId(idea.Id);

            if (idea.UserId != userId)
            {
                throw new PermissionException();
            }
            string statusKey = ideaData.FetchStatusKey(idea.Id);

            if (statusKey != IdeaStatusKeys.DRAFT && statusKey != IdeaStatusKeys.SUBMITTED)
            {
                throw new CustomException("Error: Idea with submitted status can only be updated.");
            }
            IdeaValidator validator = new IdeaValidator(settingsData.GetGroupSettings(SettingsKeys.IdeaForm.GroupKEY));

            if (!validator.IsValid(idea))
            {
                throw new FormException(validator.ErrorCodes);
            }
            foreach (var file in idea.Files.Where(file => file.Id == 0))
            {
                file.Thumbnail = fileProcess.GetThumbnail(file);
            }
            int id = ideaData.Update(idea);

            return(id);
        }
Example #3
0
        public int Save(IdeaDataObject idea)
        {
            IdeaValidator validator = new IdeaValidator(settingsData.GetGroupSettings(SettingsKeys.IdeaForm.GroupKEY));

            if (!validator.IsValid(idea))
            {
                throw new FormException(validator.ErrorCodes);
            }

            foreach (var file in idea.Files)
            {
                file.Thumbnail = fileProcess.GetThumbnail(file);
            }

            return(ideaData.Insert(idea));
        }