コード例 #1
0
ファイル: Topics.cs プロジェクト: mfcharaf/SnitzDotNet
        public static void Delete(int topicid)
        {
            Subscriptions.RemoveAllTopicSubscriptions(topicid);
            ITopic dal = Factory <ITopic> .Create("Topic");

            TopicInfo topic = GetTopic(topicid);

            dal.Delete(topic);
        }
コード例 #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var topicToDelete = _topicService.GetById(id);

            try
            {
                await _topicService.Delete(id);
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                return(RedirectToAction("Delete", new { id, saveChangesError = true }));
            }

            return(RedirectToAction("TopicsByCategory", "Topics", new { id = topicToDelete.Category.Id }));
        }
コード例 #3
0
        public async Task <IActionResult> Delete(int id)
        {
            var topicToDelete = _topicService.GetById(id);

            if (topicToDelete == null)
            {
                return(NotFound());
            }
            try
            {
                await _topicService.Delete(id);
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                return(BadRequest("Unable to delete. Try again..."));
            }
            return(NoContent());
        }