コード例 #1
0
        public ActionResult EditLibrary(string btnAddTopic, string btnAddSubTopic, string btnShowFolder, string btnHideFolder, FormCollection collection)
        {
            string SpecialityId = collection["DisplaySpecialityId"];


            if (btnAddTopic != null)
            {
                switch (btnAddTopic)
                {
                case "Add":
                    if (!string.IsNullOrEmpty(collection["FolderName0"].Trim()))
                    {
                        var Result = MyLibraryBL.AddTopic(int.Parse(SpecialityId), collection["FolderName0"], CurrentUser.UserId);
                    }
                    break;
                }
            }
            if (btnAddSubTopic != null)
            {
                string TopicId      = collection["FolderParent"];
                string SubTopicName = collection["FolderName" + TopicId];
                switch (btnAddSubTopic)
                {
                case "Add":
                    if (!string.IsNullOrEmpty(SubTopicName.Trim()))
                    {
                        var Result = MyLibraryBL.AddSubTopic(TopicId, SubTopicName, CurrentUser.UserId);
                    }
                    break;
                }
            }

            // For Hiding User Topics and User SubTopics
            if (btnHideFolder != null)
            {
                if (collection["TopicIdCheckboxList"] != null)
                {
                    // Checking Selected Topics and Displying Hide
                    var        TopicIdCheckboxList = collection["TopicIdCheckboxList"];
                    List <int> TopicIds            = new List <int>(TopicIdCheckboxList.Split(',').Select(int.Parse));
                    MyLibraryBL.HideTopics(TopicIds, CurrentUser.UserId);
                }

                // Checking Selected SubTopics and Displying Hide
                if (collection["SubTopicIdCheckboxList"] != null)
                {
                    var        SubTopicIdCheckboxList = collection["SubTopicIdCheckboxList"];
                    List <int> SubTopicIds            = new List <int>(SubTopicIdCheckboxList.Split(',').Select(int.Parse));
                    MyLibraryBL.HideSubTopics(SubTopicIds, CurrentUser.UserId);
                }
            }

            // For Showing User Topics and User SubTopics
            if (btnShowFolder != null)
            {
                // For Topics Show Folder
                if (collection["TopicIdCheckboxList"] != null)
                {
                    var        TopicIdCheckboxList = collection["TopicIdCheckboxList"];
                    List <int> TopicIds            = new List <int>(TopicIdCheckboxList.Split(',').Select(int.Parse));
                    MyLibraryBL.ShowTopics(TopicIds, CurrentUser.UserId);
                }

                // Checking Selected SubTopics and Displying Hide
                if (collection["SubTopicIdCheckboxList"] != null)
                {
                    var        SubTopicIdCheckboxList = collection["SubTopicIdCheckboxList"];
                    List <int> SubTopicIds            = new List <int>(SubTopicIdCheckboxList.Split(',').Select(int.Parse));
                    MyLibraryBL.ShowSubTopics(SubTopicIds, CurrentUser.UserId);
                }
            }
            return(RedirectToAction("EditLibrary", new { specid = SpecialityId }));
        }