Exemple #1
0
        public IActionResult TopicCreateAjax(Topic topic)
        {
            if (_TopicManager.Exists(topic.Name))
            {
                return(Json(new { status = false, message = "Topic is exist" }));
            }

            _TopicManager.Add(topic);
            return(Json(new { status = true, message = "Add new topic success" }));
        }
        /// <summary>
        /// Create a new topic/thread for a class/module
        /// </summary>
        /// <param name="discussionViewModel">Topic View Model</param>
        /// <returns>TopicViewModel if created successfully otherwise null</returns>
        public TopicViewModel AddTopic(TopicViewModel topicViewModel)
        {
            Topic _topic = new Topic();

            try
            {
                _topic             = ObjectMapper.Map <TopicViewModel, Topic>(topicViewModel);
                _topic.PublishFrom = DateTime.Now;
                _topic.PublishTo   = DateTime.Now;
                Topic newTopicPost = TopicManager.Add(_topic);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
                return(null);
            }
            TopicViewModel _topicViewModel = ObjectMapper.Map <Topic, TopicViewModel>(_topic);

            return(_topicViewModel);
        }