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());
        }
예제 #2
0
        public void Setup_OkState()
        {
            _rdValidatorMock = new Mock <IRequirementDefinitionValidator>();
            _rdValidatorMock.Setup(r => r.ExistsAsync(_rd1Id, default)).Returns(Task.FromResult(true));
            _rdValidatorMock.Setup(r => r.ExistsAsync(_rd2Id, default)).Returns(Task.FromResult(true));
            _rdValidatorMock.Setup(r => r.UsageCoversBothForSupplierAndOtherAsync(new List <int> {
                _rd1Id, _rd2Id
            }, default)).Returns(Task.FromResult(true));

            _command = new UpdateRequirementsCommand("", "",
                                                     new List <RequirementForCommand>
            {
                new RequirementForCommand(_rd1Id, 1),
                new RequirementForCommand(_rd2Id, 1)
            });

            _dut = new UpdateRequirementsCommandValidator(_rdValidatorMock.Object);
        }