internal VLLibraryQuestion CreateLibraryQuestion(VLLibraryQuestion question, short textsLanguage = /*DefaultLanguage*/ -2) { if (question == null) { throw new ArgumentNullException("question"); } question.ValidateInstance(); #region SecurityLayer if (this.PrincipalType == Core.PrincipalType.SystemUser) { CheckPermissions(VLPermissions.ManageSystem, VLPermissions.Developer, VLPermissions.SystemService, VLPermissions.ManageBuidingBlocks); } else { throw new VLAccessDeniedException(); } #endregion /*Υπάρχει η κατηγορία?*/ var category = LibrariesDal.GetLibraryQuestionCategoryById(this.AccessTokenId, question.Category); if (category == null) { throw new VLException(SR.GetString(SR.There_is_no_item_with_id, "LibraryQuestionCategory", question.Category)); } return(LibrariesDal.CreateLibraryQuestion(this.AccessTokenId, question)); }
public VLLibraryQuestion UpdateLibraryQuestion(VLLibraryQuestion question) { #region input parameters validation if (question == null) { throw new ArgumentNullException("question"); } question.ValidateInstance(); #endregion #region SecurityLayer if (this.PrincipalType == Core.PrincipalType.SystemUser) { CheckPermissions(VLPermissions.ManageSystem, VLPermissions.Developer, VLPermissions.SystemService, VLPermissions.ManageBuidingBlocks); } else { throw new VLAccessDeniedException(); } #endregion //Υπάρχει η ερώτησή στο σύστημα: var existingItem = LibrariesDal.GetLibraryQuestionById(AccessTokenId, question.QuestionId, question.TextsLanguage); if (existingItem == null) { throw new VLException(SR.GetString(SR.There_is_no_item_with_id, "Question", question.QuestionId)); } //Δεν μπορούμε να αλλάξουμε τον τύπο της ερώτησης στο update: if (existingItem.QuestionType != question.QuestionType) { throw new VLException(string.Format("You cannot change the questionType of an existing question from {0} to {1}!", existingItem.QuestionType.ToString(), question.QuestionType.ToString())); } /*Ελέγχουμε την εγκυρότητα της αλλαγμένης ερώτησης, που πάμε να αποθηκεύσουμε:*/ _Validatequestion(question); //existingItem.Category = question.Category; //existingItem.QuestionType = question.QuestionType; existingItem.IsRequired = question.IsRequired; existingItem.RequiredBehavior = question.RequiredBehavior; existingItem.RequiredMinLimit = question.RequiredMinLimit; existingItem.RequiredMaxLimit = question.RequiredMaxLimit; //AttributeFlags existingItem.OptionalInputBox = question.OptionalInputBox; existingItem.RandomizeOptionsSequence = question.RandomizeOptionsSequence; existingItem.DoNotRandomizeLastOption = question.DoNotRandomizeLastOption; existingItem.RandomizeColumnSequence = question.RandomizeColumnSequence; existingItem.OneResponsePerColumn = question.OneResponsePerColumn; existingItem.AddResetLink = question.AddResetLink; existingItem.UseDateTimeControls = question.UseDateTimeControls; existingItem.ValidationBehavior = question.ValidationBehavior; existingItem.ValidationField1 = question.ValidationField1; existingItem.ValidationField2 = question.ValidationField2; existingItem.ValidationField3 = question.ValidationField3; existingItem.RegularExpression = question.RegularExpression; existingItem.RandomBehavior = question.RandomBehavior; existingItem.OtherFieldType = question.OtherFieldType; existingItem.OtherFieldRows = question.OtherFieldRows; existingItem.OtherFieldChars = question.OtherFieldChars; //OptionsSequence //ColumnsSequence existingItem.RangeStart = question.RangeStart; existingItem.RangeEnd = question.RangeEnd; //TextsLanguage existingItem.QuestionText = question.QuestionText; existingItem.Description = question.Description; existingItem.HelpText = question.HelpText; existingItem.FrontLabelText = question.FrontLabelText; existingItem.AfterLabelText = question.AfterLabelText; existingItem.InsideText = question.InsideText; existingItem.RequiredMessage = question.RequiredMessage; existingItem.ValidationMessage = question.ValidationMessage; existingItem.OtherFieldLabel = question.OtherFieldLabel; return(LibrariesDal.UpdateLibraryQuestion(AccessTokenId, existingItem)); }