Exemple #1
0
        public IActionResult GetTopicId(Guid id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            var topic = getByIdTopicUseCase.GetById(id);

            return(new OkObjectResult(topic));
        }
Exemple #2
0
        public IActionResult CreatePost(string title, string content, Guid topicId, Guid userId)
        {
            var topic = getByIdTopicUseCase.GetById(topicId);

            if (topic == null && getByIdUserUseCase.GetById(userId) == null)
            {
                return(BadRequest());
            }
            var    user   = getByIdUserUseCase.GetById(userId);
            string author = user.Name;

            var post = new Domain.Entities.Post(title, content, topic, user);

            var validationResult = new PostValidator().Validate(post);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }

            addPostUseCase.Add(post);
            return(new OkObjectResult(post));
        }