コード例 #1
0
        public void DeleteLibraryQuestion(Int32 questionId)
        {
            var existingItem = LibrariesDal.GetLibraryQuestionById(this.AccessTokenId, questionId);

            if (existingItem == null)
            {
                throw new VLException(SR.GetString(SR.There_is_no_item_with_id, "LibraryQuestion", questionId));
            }


            #region SecurityLayer
            if (this.PrincipalType == Core.PrincipalType.SystemUser)
            {
                CheckPermissions(VLPermissions.ManageSystem, VLPermissions.Developer, VLPermissions.SystemService, VLPermissions.ManageBuidingBlocks);
            }
            else
            {
                throw new VLAccessDeniedException();
            }
            #endregion

            //Δεν μπορούμε να διαγράψουμε την συγκεκριμένη ερώτηση εάν έχει ήδη χρησιμοποιηθεί:
            if (SurveysDal.GetQuestionsForLibraryQuestionCount(this.AccessTokenId, existingItem.QuestionId) > 0)
            {
                throw new VLException("You cannot delete this LibraryQuestion! It is been used by Survey Questions!");
            }



            LibrariesDal.DeleteLibraryQuestion(this.AccessTokenId, questionId);
        }
コード例 #2
0
        public VLLibraryQuestion GetLibraryQuestionById(Int32 questionId, short textsLanguage = /*DefaultLanguage*/ -2)
        {
            #region SecurityLayer
            #endregion

            return(LibrariesDal.GetLibraryQuestionById(this.AccessTokenId, questionId, textsLanguage));
        }
コード例 #3
0
        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));
        }