示例#1
0
        public async Task <IActionResult> Delete(int id)
        {
            var redirectPath = ForumViewResult.GetReferrer(this);

            if (ModelState.IsValid)
            {
                var topic = await DbContext.Topics.SingleAsync(m => m.Id == id);

                await TopicRepository.RemoveTopic(topic);

                await DbContext.SaveChangesAsync();

                await ForumHub.Clients.All.SendAsync("deleted-topic", new HubModels.Message {
                    TopicId   = topic.Id,
                    MessageId = 0
                });

                redirectPath = Url.Action(nameof(Topics.Index), nameof(Topics));
            }

            return(Redirect(redirectPath));
        }