Exemplo n.º 1
0
        public async Task <IActionResult> CreateTopic([FromBody] CreateTopic newTopic)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new { IsSuccess = false, Message = "" }));
                }
                else
                {
                    var currentUser = _userRepository.GetByIdAsync(_userAppContext.CurrentUserId);
                    newTopic.OwnerId = currentUser.Id;
                    newTopic.UserUId = currentUser.UId;
                    var topicCreated = await _blockService.CreateTopic(newTopic);

                    return(Json(new { IsSuccess = true, Topic = topicCreated }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { IsSuccess = false, Message = e.Message }));
            }
        }