public virtual ApiPipelineStepDestinationServerResponseModel MapEntityToModel(
            PipelineStepDestination item)
        {
            var model = new ApiPipelineStepDestinationServerResponseModel();

            model.SetProperties(item.Id,
                                item.DestinationId,
                                item.PipelineStepId);
            if (item.DestinationIdNavigation != null)
            {
                var destinationIdModel = new ApiDestinationServerResponseModel();
                destinationIdModel.SetProperties(
                    item.DestinationIdNavigation.Id,
                    item.DestinationIdNavigation.CountryId,
                    item.DestinationIdNavigation.Name,
                    item.DestinationIdNavigation.Order);

                model.SetDestinationIdNavigation(destinationIdModel);
            }

            if (item.PipelineStepIdNavigation != null)
            {
                var pipelineStepIdModel = new ApiPipelineStepServerResponseModel();
                pipelineStepIdModel.SetProperties(
                    item.PipelineStepIdNavigation.Id,
                    item.PipelineStepIdNavigation.Name,
                    item.PipelineStepIdNavigation.PipelineStepStatusId,
                    item.PipelineStepIdNavigation.ShipperId);

                model.SetPipelineStepIdNavigation(pipelineStepIdModel);
            }

            return(model);
        }
Example #2
0
        public virtual ApiDestinationClientRequestModel MapServerResponseToClientRequest(
            ApiDestinationServerResponseModel response)
        {
            var request = new ApiDestinationClientRequestModel();

            request.SetProperties(
                response.CountryId,
                response.Name,
                response.Order);
            return(request);
        }
Example #3
0
        public virtual ApiDestinationServerResponseModel MapServerRequestToResponse(
            int id,
            ApiDestinationServerRequestModel request)
        {
            var response = new ApiDestinationServerResponseModel();

            response.SetProperties(id,
                                   request.CountryId,
                                   request.Name,
                                   request.Order);
            return(response);
        }
        public void MapEntityToModel()
        {
            var         mapper = new DALDestinationMapper();
            Destination item   = new Destination();

            item.SetProperties(1, 1, "A", 1);
            ApiDestinationServerResponseModel response = mapper.MapEntityToModel(item);

            response.CountryId.Should().Be(1);
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.Order.Should().Be(1);
        }
        public virtual ApiDestinationServerResponseModel MapEntityToModel(
            Destination item)
        {
            var model = new ApiDestinationServerResponseModel();

            model.SetProperties(item.Id,
                                item.CountryId,
                                item.Name,
                                item.Order);
            if (item.CountryIdNavigation != null)
            {
                var countryIdModel = new ApiCountryServerResponseModel();
                countryIdModel.SetProperties(
                    item.CountryIdNavigation.Id,
                    item.CountryIdNavigation.Name);

                model.SetCountryIdNavigation(countryIdModel);
            }

            return(model);
        }
Example #6
0
        public virtual async Task <UpdateResponse <ApiDestinationServerResponseModel> > Update(
            int id,
            ApiDestinationServerRequestModel model)
        {
            var validationResult = await this.DestinationModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Destination record = this.DalDestinationMapper.MapModelToEntity(id, model);
                await this.DestinationRepository.Update(record);

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

                ApiDestinationServerResponseModel apiModel = this.DalDestinationMapper.MapEntityToModel(record);
                await this.mediator.Publish(new DestinationUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiDestinationServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiDestinationServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Example #7
0
 public void SetDestinationIdNavigation(ApiDestinationServerResponseModel value)
 {
     this.DestinationIdNavigation = value;
 }
Example #8
0
 public DestinationUpdatedNotification(ApiDestinationServerResponseModel record)
 {
     this.Record = record;
 }