/// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="textsLanguage"></param>
        /// <returns></returns>
        public VLLibraryQuestionCategory CreateLibraryQuestionCategory(string name, short textsLanguage = -2)
        {
            Utility.CheckParameter(ref name, true, true, false, 128, "Name");

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


            /*
             * Ελέγχουμε εάν υπάρχει ήδη στην βάση αυτό το name, σε οποιαδήποτε γλώσσα:
             */
            var existingItem = LibrariesDal.GetLibraryQuestionCategoryByName(this.AccessTokenId, name, textsLanguage);
            if (existingItem != null)
            {
                throw new VLException(SR.GetString(SR.Value_is_already_in_use, "Name", name));
            }

            var category = new VLLibraryQuestionCategory();
            category.Name = name;
            return(LibrariesDal.CreateLibraryQuestionCategory(this.AccessTokenId, category, textsLanguage));
        }
 public void DeleteLibraryQuestionCategory(VLLibraryQuestionCategory category)
 {
     if (category == null)
     {
         throw new ArgumentNullException("category");
     }
     DeleteLibraryQuestionCategory(category.CategoryId);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public VLLibraryQuestionCategory UpdateLibraryQuestionCategory(VLLibraryQuestionCategory category)
        {
            if (category == null)
            {
                throw new ArgumentNullException("category");
            }
            category.ValidateInstance();

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

            /*Το name κάθε κατηγορίας πρέπει να είναι μοναδικό*/
            var existingItem = LibrariesDal.GetLibraryQuestionCategoryByName(this.AccessTokenId, category.Name, category.TextsLanguage);
            if (existingItem != null && existingItem.CategoryId != category.CategoryId)
            {
                throw new VLException(SR.GetString(SR.Value_is_already_in_use, "Name", category.Name));
            }
            if (existingItem == null)
            {
                existingItem = LibrariesDal.GetLibraryQuestionCategoryById(AccessTokenId, category.CategoryId, category.TextsLanguage);
            }
            if (existingItem == null)
            {
                throw new VLException(SR.GetString(SR.There_is_no_item_with_id, "LibraryQuestionCategory", category.CategoryId));
            }

            existingItem.AttributeFlags = category.AttributeFlags;
            existingItem.Name           = category.Name;

            return(LibrariesDal.UpdateLibraryQuestionCategory(this.AccessTokenId, existingItem));
        }