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)); }
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)); }
public int Update(Domain.Entities.Topic topic) { return(topicWriteOnlyUseCase.Update(topic)); }
public int Remove(Domain.Entities.Topic entity) { return(topicWriteOnlyUseCase.Remove(entity)); }
public int Add(Domain.Entities.Topic topic) { return(topicWriteOnlyUseCase.Add(topic)); }