public async Task <ValidationResult> ValidateUpdateAsync(string id, ApiDeploymentProcessRequestModel model)
 {
     this.IsFrozenRules();
     this.JSONRules();
     this.OwnerIdRules();
     this.RelatedDocumentIdsRules();
     this.VersionRules();
     return(await this.ValidateAsync(model, id));
 }
        private async Task <ApiDeploymentProcessResponseModel> CreateRecord()
        {
            var model = new ApiDeploymentProcessRequestModel();

            model.SetProperties(true, "B", "B", "B", 2);
            CreateResponse <ApiDeploymentProcessResponseModel> result = await this.Client.DeploymentProcessCreateAsync(model);

            result.Success.Should().BeTrue();
            return(result.Record);
        }
Ejemplo n.º 3
0
        public virtual async Task <IActionResult> Create([FromBody] ApiDeploymentProcessRequestModel model)
        {
            CreateResponse <ApiDeploymentProcessResponseModel> result = await this.DeploymentProcessService.Create(model);

            if (result.Success)
            {
                return(this.Created($"{this.Settings.ExternalBaseUrl}/api/DeploymentProcesses/{result.Record.Id}", result));
            }
            else
            {
                return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
            }
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiDeploymentProcessModelMapper();
            var model  = new ApiDeploymentProcessResponseModel();

            model.SetProperties("A", true, "A", "A", "A", 1);
            ApiDeploymentProcessRequestModel response = mapper.MapResponseToRequest(model);

            response.IsFrozen.Should().Be(true);
            response.JSON.Should().Be("A");
            response.OwnerId.Should().Be("A");
            response.RelatedDocumentIds.Should().Be("A");
            response.Version.Should().Be(1);
        }
Ejemplo n.º 5
0
        public void MapModelToBO()
        {
            var mapper = new BOLDeploymentProcessMapper();
            ApiDeploymentProcessRequestModel model = new ApiDeploymentProcessRequestModel();

            model.SetProperties(true, "A", "A", "A", 1);
            BODeploymentProcess response = mapper.MapModelToBO("A", model);

            response.IsFrozen.Should().Be(true);
            response.JSON.Should().Be("A");
            response.OwnerId.Should().Be("A");
            response.RelatedDocumentIds.Should().Be("A");
            response.Version.Should().Be(1);
        }
        public virtual async Task <CreateResponse <ApiDeploymentProcessResponseModel> > Create(
            ApiDeploymentProcessRequestModel model)
        {
            CreateResponse <ApiDeploymentProcessResponseModel> response = new CreateResponse <ApiDeploymentProcessResponseModel>(await this.deploymentProcessModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                var bo     = this.bolDeploymentProcessMapper.MapModelToBO(default(string), model);
                var record = await this.deploymentProcessRepository.Create(this.dalDeploymentProcessMapper.MapBOToEF(bo));

                response.SetRecord(this.bolDeploymentProcessMapper.MapBOToModel(this.dalDeploymentProcessMapper.MapEFToBO(record)));
            }

            return(response);
        }
Ejemplo n.º 7
0
        private async Task <ApiDeploymentProcessRequestModel> PatchModel(string id, JsonPatchDocument <ApiDeploymentProcessRequestModel> patch)
        {
            var record = await this.DeploymentProcessService.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                ApiDeploymentProcessRequestModel request = this.DeploymentProcessModelMapper.MapResponseToRequest(record);
                patch.ApplyTo(request);
                return(request);
            }
        }
Ejemplo n.º 8
0
        public virtual BODeploymentProcess MapModelToBO(
            string id,
            ApiDeploymentProcessRequestModel model
            )
        {
            BODeploymentProcess boDeploymentProcess = new BODeploymentProcess();

            boDeploymentProcess.SetProperties(
                id,
                model.IsFrozen,
                model.JSON,
                model.OwnerId,
                model.RelatedDocumentIds,
                model.Version);
            return(boDeploymentProcess);
        }
        public void CreatePatch()
        {
            var mapper = new ApiDeploymentProcessModelMapper();
            var model  = new ApiDeploymentProcessRequestModel();

            model.SetProperties(true, "A", "A", "A", 1);

            JsonPatchDocument <ApiDeploymentProcessRequestModel> patch = mapper.CreatePatch(model);
            var response = new ApiDeploymentProcessRequestModel();

            patch.ApplyTo(response);
            response.IsFrozen.Should().Be(true);
            response.JSON.Should().Be("A");
            response.OwnerId.Should().Be("A");
            response.RelatedDocumentIds.Should().Be("A");
            response.Version.Should().Be(1);
        }
Ejemplo n.º 10
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IDeploymentProcessRepository>();
            var model = new ApiDeploymentProcessRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <DeploymentProcess>())).Returns(Task.FromResult(new DeploymentProcess()));
            var service = new DeploymentProcessService(mock.LoggerMock.Object,
                                                       mock.RepositoryMock.Object,
                                                       mock.ModelValidatorMockFactory.DeploymentProcessModelValidatorMock.Object,
                                                       mock.BOLMapperMockFactory.BOLDeploymentProcessMapperMock,
                                                       mock.DALMapperMockFactory.DALDeploymentProcessMapperMock);

            CreateResponse <ApiDeploymentProcessResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.DeploymentProcessModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiDeploymentProcessRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <DeploymentProcess>()));
        }
Ejemplo n.º 11
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IDeploymentProcessRepository>();
            var model = new ApiDeploymentProcessRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.CompletedTask);
            var service = new DeploymentProcessService(mock.LoggerMock.Object,
                                                       mock.RepositoryMock.Object,
                                                       mock.ModelValidatorMockFactory.DeploymentProcessModelValidatorMock.Object,
                                                       mock.BOLMapperMockFactory.BOLDeploymentProcessMapperMock,
                                                       mock.DALMapperMockFactory.DALDeploymentProcessMapperMock);

            ActionResponse response = await service.Delete(default(string));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <string>()));
            mock.ModelValidatorMockFactory.DeploymentProcessModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <string>()));
        }
        public virtual async Task <UpdateResponse <ApiDeploymentProcessResponseModel> > Update(
            string id,
            ApiDeploymentProcessRequestModel model)
        {
            var validationResult = await this.deploymentProcessModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                var bo = this.bolDeploymentProcessMapper.MapModelToBO(id, model);
                await this.deploymentProcessRepository.Update(this.dalDeploymentProcessMapper.MapBOToEF(bo));

                var record = await this.deploymentProcessRepository.Get(id);

                return(new UpdateResponse <ApiDeploymentProcessResponseModel>(this.bolDeploymentProcessMapper.MapBOToModel(this.dalDeploymentProcessMapper.MapEFToBO(record))));
            }
            else
            {
                return(new UpdateResponse <ApiDeploymentProcessResponseModel>(validationResult));
            }
        }
Ejemplo n.º 13
0
        public virtual async Task <IActionResult> Update(string id, [FromBody] ApiDeploymentProcessRequestModel model)
        {
            ApiDeploymentProcessRequestModel request = await this.PatchModel(id, this.DeploymentProcessModelMapper.CreatePatch(model));

            if (request == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                UpdateResponse <ApiDeploymentProcessResponseModel> result = await this.DeploymentProcessService.Update(id, request);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Ejemplo n.º 14
0
        public virtual async Task <IActionResult> Patch(string id, [FromBody] JsonPatchDocument <ApiDeploymentProcessRequestModel> patch)
        {
            ApiDeploymentProcessResponseModel record = await this.DeploymentProcessService.Get(id);

            if (record == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                ApiDeploymentProcessRequestModel model = await this.PatchModel(id, patch);

                UpdateResponse <ApiDeploymentProcessResponseModel> result = await this.DeploymentProcessService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }