Exemplo n.º 1
0
        public IActionResult UpdateTopic(Guid userTypeId, Guid categoryId, Guid id, string name)
        {
            var userType = getByIdUserUseCase.GetById(userTypeId);
            var category = getByIdCategoryUseCase.GetById(categoryId);
            var topicId  = getByIdTopicUseCase.GetById(id);

            if (userType.Id == null || userType.UserType != 1)
            {
                return(BadRequest("Erro ao reconhecer o usuario"));
            }
            if (category == null && topicId == null)
            {
                return(BadRequest());
            }

            var topic = new Domain.Entities.Topic(topicId.Id, name, topicId.CreatedAt);

            updateTopicUseCase.Update(topic);
            return(new OkObjectResult(topic));
        }
Exemplo n.º 2
0
        public IActionResult CreateTopic(string name, Guid categoryId)
        {
            var category = getByIdCategoryUseCase.GetById(categoryId);

            if (category == null)
            {
                return(BadRequest("Category PK not found"));
            }

            var topic = new Domain.Entities.Topic(name, category);

            var validationResult = new TopicValidator().Validate(topic);

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

            addTopicUseCase.Add(topic);
            return(new OkObjectResult(topic));
        }
Exemplo n.º 3
0
 public int Update(Domain.Entities.Topic topic)
 {
     return(topicWriteOnlyUseCase.Update(topic));
 }
Exemplo n.º 4
0
 public int Remove(Domain.Entities.Topic entity)
 {
     return(topicWriteOnlyUseCase.Remove(entity));
 }
Exemplo n.º 5
0
 public int Add(Domain.Entities.Topic topic)
 {
     return(topicWriteOnlyUseCase.Add(topic));
 }