Exemple #1
0
        /// <summary>
        /// Creates ItemCategories object by calling ItemCategories data provider create method.
        /// <example>[Example]bool status=ItemCategoriesFactory.Create(itemCategoriesObject);.</example>
        /// </summary>
        /// <param name="itemCategoriesObject">The ItemCategories object.</param>
        /// <returns>Status of create operation.</returns>
        public static ExecuteCommandStatus Create(ItemCategoriesEntity category, ItemsModulesOptions currentModule)
        {
            //Insert user name------------------------------------------
            string username = "";

            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                username = HttpContext.Current.User.Identity.Name;
                category.InsertUserName = username;
            }
            //----------------------------------------------------------
            ExecuteCommandStatus status = ItemCategoriesSqlDataPrvider.Instance.Create(category, currentModule);

            //-------------------------------------
            if (status == ExecuteCommandStatus.Done)
            {
                string folder             = DCSiteUrls.GetPath_ItemCategoriesDirectory(category.OwnerName, category.ModuleTypeID, category.CategoryID);
                string folderPhysicalPath = DCServer.MapPath(folder);
                if (!Directory.Exists(folderPhysicalPath))
                {
                    string        defaultFolder             = DCSiteUrls.GetPath_DefaultCategoryFolder();
                    string        defaultFolderPhysicalPath = DCServer.MapPath(defaultFolder);
                    DirectoryInfo diSource = new DirectoryInfo(defaultFolderPhysicalPath);
                    DirectoryInfo diTarget = new DirectoryInfo(folderPhysicalPath);
                    DcDirectoryManager.CopyAll(diSource, diTarget);
                }
            }
            //-------------------------------------
            return(status);
        }
Exemple #2
0
        //------------------------------------------
        #endregion

        #region --------------Delete--------------
        /// <summary>
        /// Deletes single ItemCategories object .
        /// <example>[Example]bool status=ItemCategoriesFactory.Delete(categoryID);.</example>
        /// </summary>
        /// <param name="categoryID">The itemCategoriesObject id.</param>
        /// <returns>Status of delete operation.</returns>
        public static bool Delete(int CategoryID)
        {
            Languages            langID   = SiteSettings.GetCurrentLanguage();
            ItemCategoriesEntity category = GetObject(CategoryID, langID, SitesHandler.GetOwnerIDAsGuid());
            bool status = ItemCategoriesSqlDataPrvider.Instance.Delete(CategoryID);

            if (status)
            {
                //-------------------------------------
                //delete category folder
                //-------------------------------------
                string folder             = DCSiteUrls.GetPath_ItemCategoriesDirectory(category.OwnerName, category.ModuleTypeID, category.CategoryID);
                string folderPhysicalPath = DCServer.MapPath(folder);
                if (Directory.Exists(folderPhysicalPath))
                {
                    DirectoryInfo dir = new DirectoryInfo(folderPhysicalPath);
                    DcDirectoryManager.DeletDirectory(dir);
                }
                //-------------------------------------
            }
            return(status);
        }