public void MapModelToBO()
        {
            var mapper = new BOLPipelineStepStatusMapper();
            ApiPipelineStepStatusRequestModel model = new ApiPipelineStepStatusRequestModel();

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

            response.Name.Should().Be("A");
        }
Exemple #2
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiPipelineStepStatusModelMapper();
            var model  = new ApiPipelineStepStatusResponseModel();

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

            response.Name.Should().Be("A");
        }
        private async Task <ApiPipelineStepStatusResponseModel> CreateRecord()
        {
            var model = new ApiPipelineStepStatusRequestModel();

            model.SetProperties("B");
            CreateResponse <ApiPipelineStepStatusResponseModel> result = await this.Client.PipelineStepStatusCreateAsync(model);

            result.Success.Should().BeTrue();
            return(result.Record);
        }
Exemple #4
0
        public virtual BOPipelineStepStatus MapModelToBO(
            int id,
            ApiPipelineStepStatusRequestModel model
            )
        {
            BOPipelineStepStatus boPipelineStepStatus = new BOPipelineStepStatus();

            boPipelineStepStatus.SetProperties(
                id,
                model.Name);
            return(boPipelineStepStatus);
        }
        public virtual async Task <IActionResult> Create([FromBody] ApiPipelineStepStatusRequestModel model)
        {
            CreateResponse <ApiPipelineStepStatusResponseModel> result = await this.PipelineStepStatusService.Create(model);

            if (result.Success)
            {
                return(this.Created($"{this.Settings.ExternalBaseUrl}/api/PipelineStepStatus/{result.Record.Id}", result));
            }
            else
            {
                return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
            }
        }
Exemple #6
0
        public void CreatePatch()
        {
            var mapper = new ApiPipelineStepStatusModelMapper();
            var model  = new ApiPipelineStepStatusRequestModel();

            model.SetProperties("A");

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

            patch.ApplyTo(response);
            response.Name.Should().Be("A");
        }
        private async Task <ApiPipelineStepStatusRequestModel> PatchModel(int id, JsonPatchDocument <ApiPipelineStepStatusRequestModel> patch)
        {
            var record = await this.PipelineStepStatusService.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                ApiPipelineStepStatusRequestModel request = this.PipelineStepStatusModelMapper.MapResponseToRequest(record);
                patch.ApplyTo(request);
                return(request);
            }
        }
        public virtual async Task <CreateResponse <ApiPipelineStepStatusResponseModel> > Create(
            ApiPipelineStepStatusRequestModel model)
        {
            CreateResponse <ApiPipelineStepStatusResponseModel> response = new CreateResponse <ApiPipelineStepStatusResponseModel>(await this.pipelineStepStatusModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                var bo     = this.bolPipelineStepStatusMapper.MapModelToBO(default(int), model);
                var record = await this.pipelineStepStatusRepository.Create(this.dalPipelineStepStatusMapper.MapBOToEF(bo));

                response.SetRecord(this.bolPipelineStepStatusMapper.MapBOToModel(this.dalPipelineStepStatusMapper.MapEFToBO(record)));
            }

            return(response);
        }
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IPipelineStepStatusRepository>();
            var model = new ApiPipelineStepStatusRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <PipelineStepStatus>())).Returns(Task.FromResult(new PipelineStepStatus()));
            var service = new PipelineStepStatusService(mock.LoggerMock.Object,
                                                        mock.RepositoryMock.Object,
                                                        mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Object,
                                                        mock.BOLMapperMockFactory.BOLPipelineStepStatusMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepStatusMapperMock,
                                                        mock.BOLMapperMockFactory.BOLPipelineStepMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepMapperMock);

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

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiPipelineStepStatusRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <PipelineStepStatus>()));
        }
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IPipelineStepStatusRepository>();
            var model = new ApiPipelineStepStatusRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new PipelineStepStatusService(mock.LoggerMock.Object,
                                                        mock.RepositoryMock.Object,
                                                        mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Object,
                                                        mock.BOLMapperMockFactory.BOLPipelineStepStatusMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepStatusMapperMock,
                                                        mock.BOLMapperMockFactory.BOLPipelineStepMapperMock,
                                                        mock.DALMapperMockFactory.DALPipelineStepMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.PipelineStepStatusModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
        }
        public virtual async Task <UpdateResponse <ApiPipelineStepStatusResponseModel> > Update(
            int id,
            ApiPipelineStepStatusRequestModel model)
        {
            var validationResult = await this.pipelineStepStatusModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                var bo = this.bolPipelineStepStatusMapper.MapModelToBO(id, model);
                await this.pipelineStepStatusRepository.Update(this.dalPipelineStepStatusMapper.MapBOToEF(bo));

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

                return(new UpdateResponse <ApiPipelineStepStatusResponseModel>(this.bolPipelineStepStatusMapper.MapBOToModel(this.dalPipelineStepStatusMapper.MapEFToBO(record))));
            }
            else
            {
                return(new UpdateResponse <ApiPipelineStepStatusResponseModel>(validationResult));
            }
        }
        public virtual async Task <IActionResult> Update(int id, [FromBody] ApiPipelineStepStatusRequestModel model)
        {
            ApiPipelineStepStatusRequestModel request = await this.PatchModel(id, this.PipelineStepStatusModelMapper.CreatePatch(model));

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

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiPipelineStepStatusRequestModel> patch)
        {
            ApiPipelineStepStatusResponseModel record = await this.PipelineStepStatusService.Get(id);

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

                UpdateResponse <ApiPipelineStepStatusResponseModel> result = await this.PipelineStepStatusService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
 public async Task <ValidationResult> ValidateUpdateAsync(int id, ApiPipelineStepStatusRequestModel model)
 {
     this.NameRules();
     return(await this.ValidateAsync(model, id));
 }