public void init() { List <SettingsDataObject> settings = new List <SettingsDataObject> { new SettingsDataObject { Key = "IDEA_TITLE_LENGTH", Value = "25" }, new SettingsDataObject { Key = "IDEA_CONTENT_LENGTH", Value = "1000" }, new SettingsDataObject { Key = "IDEA_FILE_LIMIT", Value = "2" }, new SettingsDataObject { Key = "IDEA_FILE_MAX_SIZE", Value = "2" }, new SettingsDataObject { Key = "IDEA_SHOW_OTHER_FIELDOFWATER", Value = "true" } }; SettingsGroupDataObject ideaSettings = new SettingsGroupDataObject(); ideaSettings.Settings = settings; validator = new IdeaValidator(ideaSettings); }
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); }
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)); }