コード例 #1
0
        public async Task <IActionResult> CreateTopic(CreateTopicModel model)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (!ModelState.IsValid || !_groupsService.IsMember(model.GroupId, userId))
            {
                return(BadRequest());
            }

            var topic = _mapper.Map <DetailsTopicModel>(_groupsService.CreateTopic(userId, model.GroupId, model.Name));

            await _groupsHubContext.Clients.Group(model.GroupId.ToString()).SendAsync("TopicCreated", model.GroupId, topic.Id, userId);

            return(Ok());
        }