public IHttpActionResult CreateUpdateRequirement([FromUri] int projectId, [FromBody] UpdateRequirementsCommand command) { if (command == null || projectId <= 0) { return(BadRequest(DefaultMessages.InvalidBody)); } List <UpdateRequirementsCommand> commands = new List <UpdateRequirementsCommand>() { command }; ValidationError error = new UpdateRequirementsCommandValidator().Validate(commands); if (error.IsInvalid) { return(BadRequest(error.Error)); } ProjectsRepository projectsRepository = new ProjectsRepository(Connection, HttpContext.Current.User); if (projectsRepository.Find(projectId) == null) { return(BadRequest("Projeto não encontrado.")); } List <Requirement> requirements = new RequirementsService().MapCommand(commands); RequirementsRepository repository = new RequirementsRepository(Connection); repository.Update(projectId, requirements); return(Ok()); }
public IHttpActionResult DeleteRequirements([FromUri] int projectId) { RequirementsRepository repository = new RequirementsRepository(Connection); repository.Delete(projectId); return(Ok()); }
public IHttpActionResult CreateTask([FromBody] CreateTaskCommand command) { if (command == null) { return(BadRequest(DefaultMessages.InvalidBody)); } ValidationError error = new CreateTaskCommandValidator().Validate(command); if (error.IsInvalid) { return(BadRequest(error.Error)); } ProjectsRepository projectsRepository = new ProjectsRepository(Connection, User); Project project = projectsRepository.Find(command.ProjectId); if (project == null) { return(BadRequest("Projeto não encontrado.")); } if (command.RequirementId > 0) { RequirementsRepository requirementsRepository = new RequirementsRepository(Connection); Requirement requirement = requirementsRepository.Find(command.ProjectId, command.RequirementId); if (requirement == null) { return(BadRequest("Requisito não encontrado neste projeto.")); } } TaskRepository taskRepository = new TaskRepository(Connection); return(Ok(taskRepository.Create(command))); }
/// <summary> /// Create and return an instance of IRequirementsRepository. /// </summary> /// <returns></returns> public static IRequirementsRepository createIRequirementsRepository() { var requirementRepository = new RequirementsRepository(createIDataTableService()); requirementRepository.Mapper = createIMapper(); requirementRepository.DateHp = createIDateHp(); requirementRepository.Hp = createHp(); return(requirementRepository); }
public void IntegrationTest_Given_ProductIdThatDoesntExistInDb_When_GetRequirementsForProductAsync_ThenReturn_Null(int productId) { //Arrange var sut = new RequirementsRepository(_context); //Act var result = sut.GetRequirementsForProductAsync(productId).Result; //Assert result.Should().BeNull(); }
public void IntegrationTest_Given_ProductId_When_GetRequirementsForProductAsync_ThenReturn_RequirementsForEditDto(int productId) { //Arrange var expected = Data.RequirementsForEditDto().Skip(productId - 1).FirstOrDefault(); var sut = new RequirementsRepository(_context); //Act var result = sut.GetRequirementsForProductAsync(productId).Result; //Assert result.Should().BeOfType <RequirementsForEditDto>(); result.Should().BeEquivalentTo(expected); }
public IHttpActionResult FindRequirements([FromUri] int projectId) { if (projectId <= 0) { return(BadRequest(DefaultMessages.InvalidBody)); } ProjectsRepository projectsRepository = new ProjectsRepository(Connection, HttpContext.Current.User); if (projectsRepository.Find(projectId) == null) { return(BadRequest("Projeto não encontrado.")); } RequirementsRepository repository = new RequirementsRepository(Connection); return(Ok(repository.Find(projectId))); }
public IHttpActionResult CreateRequirements([FromUri] int projectId, [FromBody] List <CreateRequirementsCommand> command) { if (command == null || projectId <= 0) { return(BadRequest(DefaultMessages.InvalidBody)); } ValidationError error = new CreateRequirementsCommandValidator().Validate(command); if (error.IsInvalid) { return(BadRequest(error.Error)); } ProjectsRepository projectsRepository = new ProjectsRepository(Connection, HttpContext.Current.User); if (projectsRepository.Find(projectId) == null) { return(BadRequest("Projeto não encontrado.")); } RequirementsRepository repository = new RequirementsRepository(Connection); repository.Create(projectId, command); return(Ok()); }