Example #1
0
        public JsonPatchDocument <ApiPipelineStepServerRequestModel> CreatePatch(ApiPipelineStepServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiPipelineStepServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            patch.Replace(x => x.PipelineStepStatusId, model.PipelineStepStatusId);
            patch.Replace(x => x.ShipperId, model.ShipperId);
            return(patch);
        }
Example #2
0
        public virtual ApiPipelineStepServerRequestModel MapServerResponseToRequest(
            ApiPipelineStepServerResponseModel response)
        {
            var request = new ApiPipelineStepServerRequestModel();

            request.SetProperties(
                response.Name,
                response.PipelineStepStatusId,
                response.ShipperId);
            return(request);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALPipelineStepMapper();
            ApiPipelineStepServerRequestModel model = new ApiPipelineStepServerRequestModel();

            model.SetProperties("A", 1, 1);
            PipelineStep response = mapper.MapModelToEntity(1, model);

            response.Name.Should().Be("A");
            response.PipelineStepStatusId.Should().Be(1);
            response.ShipperId.Should().Be(1);
        }
        public virtual PipelineStep MapModelToEntity(
            int id,
            ApiPipelineStepServerRequestModel model
            )
        {
            PipelineStep item = new PipelineStep();

            item.SetProperties(
                id,
                model.Name,
                model.PipelineStepStatusId,
                model.ShipperId);
            return(item);
        }
        public virtual async Task <CreateResponse <ApiPipelineStepServerResponseModel> > Create(
            ApiPipelineStepServerRequestModel model)
        {
            CreateResponse <ApiPipelineStepServerResponseModel> response = ValidationResponseFactory <ApiPipelineStepServerResponseModel> .CreateResponse(await this.PipelineStepModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                PipelineStep record = this.DalPipelineStepMapper.MapModelToEntity(default(int), model);
                record = await this.PipelineStepRepository.Create(record);

                response.SetRecord(this.DalPipelineStepMapper.MapEntityToModel(record));
                await this.mediator.Publish(new PipelineStepCreatedNotification(response.Record));
            }

            return(response);
        }
        public virtual async Task <UpdateResponse <ApiPipelineStepServerResponseModel> > Update(
            int id,
            ApiPipelineStepServerRequestModel model)
        {
            var validationResult = await this.PipelineStepModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PipelineStep record = this.DalPipelineStepMapper.MapModelToEntity(id, model);
                await this.PipelineStepRepository.Update(record);

                record = await this.PipelineStepRepository.Get(id);

                ApiPipelineStepServerResponseModel apiModel = this.DalPipelineStepMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PipelineStepUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiPipelineStepServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiPipelineStepServerResponseModel> .UpdateResponse(validationResult));
            }
        }