public JsonPatchDocument <ApiOtherTransportServerRequestModel> CreatePatch(ApiOtherTransportServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiOtherTransportServerRequestModel>();

            patch.Replace(x => x.HandlerId, model.HandlerId);
            patch.Replace(x => x.PipelineStepId, model.PipelineStepId);
            return(patch);
        }
        public virtual ApiOtherTransportServerRequestModel MapServerResponseToRequest(
            ApiOtherTransportServerResponseModel response)
        {
            var request = new ApiOtherTransportServerRequestModel();

            request.SetProperties(
                response.HandlerId,
                response.PipelineStepId);
            return(request);
        }
        public virtual ApiOtherTransportServerResponseModel MapServerRequestToResponse(
            int id,
            ApiOtherTransportServerRequestModel request)
        {
            var response = new ApiOtherTransportServerResponseModel();

            response.SetProperties(id,
                                   request.HandlerId,
                                   request.PipelineStepId);
            return(response);
        }
Beispiel #4
0
        public void MapModelToEntity()
        {
            var mapper = new DALOtherTransportMapper();
            ApiOtherTransportServerRequestModel model = new ApiOtherTransportServerRequestModel();

            model.SetProperties(1, 1);
            OtherTransport response = mapper.MapModelToEntity(1, model);

            response.HandlerId.Should().Be(1);
            response.PipelineStepId.Should().Be(1);
        }
        public virtual OtherTransport MapModelToEntity(
            int id,
            ApiOtherTransportServerRequestModel model
            )
        {
            OtherTransport item = new OtherTransport();

            item.SetProperties(
                id,
                model.HandlerId,
                model.PipelineStepId);
            return(item);
        }
        public virtual async Task <CreateResponse <ApiOtherTransportServerResponseModel> > Create(
            ApiOtherTransportServerRequestModel model)
        {
            CreateResponse <ApiOtherTransportServerResponseModel> response = ValidationResponseFactory <ApiOtherTransportServerResponseModel> .CreateResponse(await this.OtherTransportModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                OtherTransport record = this.DalOtherTransportMapper.MapModelToEntity(default(int), model);
                record = await this.OtherTransportRepository.Create(record);

                response.SetRecord(this.DalOtherTransportMapper.MapEntityToModel(record));
                await this.mediator.Publish(new OtherTransportCreatedNotification(response.Record));
            }

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

            if (validationResult.IsValid)
            {
                OtherTransport record = this.DalOtherTransportMapper.MapModelToEntity(id, model);
                await this.OtherTransportRepository.Update(record);

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

                ApiOtherTransportServerResponseModel apiModel = this.DalOtherTransportMapper.MapEntityToModel(record);
                await this.mediator.Publish(new OtherTransportUpdatedNotification(apiModel));

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