public virtual OtherTransport MapBOToEF(
            BOOtherTransport bo)
        {
            OtherTransport efOtherTransport = new OtherTransport();

            efOtherTransport.SetProperties(
                bo.HandlerId,
                bo.Id,
                bo.PipelineStepId);
            return(efOtherTransport);
        }
        public virtual BOOtherTransport MapEFToBO(
            OtherTransport ef)
        {
            var bo = new BOOtherTransport();

            bo.SetProperties(
                ef.Id,
                ef.HandlerId,
                ef.PipelineStepId);
            return(bo);
        }
Пример #3
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);
        }
Пример #4
0
        public void MapEntityToModel()
        {
            var            mapper = new DALOtherTransportMapper();
            OtherTransport item   = new OtherTransport();

            item.SetProperties(1, 1, 1);
            ApiOtherTransportServerResponseModel response = mapper.MapEntityToModel(item);

            response.HandlerId.Should().Be(1);
            response.Id.Should().Be(1);
            response.PipelineStepId.Should().Be(1);
        }
Пример #5
0
        public void MapEFToBO()
        {
            var            mapper = new DALOtherTransportMapper();
            OtherTransport entity = new OtherTransport();

            entity.SetProperties(1, 1, 1);

            BOOtherTransport response = mapper.MapEFToBO(entity);

            response.HandlerId.Should().Be(1);
            response.Id.Should().Be(1);
            response.PipelineStepId.Should().Be(1);
        }
Пример #6
0
        public void MapBOToEF()
        {
            var mapper = new DALOtherTransportMapper();
            var bo     = new BOOtherTransport();

            bo.SetProperties(1, 1, 1);

            OtherTransport response = mapper.MapBOToEF(bo);

            response.HandlerId.Should().Be(1);
            response.Id.Should().Be(1);
            response.PipelineStepId.Should().Be(1);
        }
Пример #7
0
        public virtual OtherTransport MapModelToEntity(
            int id,
            ApiOtherTransportServerRequestModel model
            )
        {
            OtherTransport item = new OtherTransport();

            item.SetProperties(
                id,
                model.HandlerId,
                model.PipelineStepId);
            return(item);
        }
Пример #8
0
        public virtual async Task <ApiOtherTransportServerResponseModel> Get(int id)
        {
            OtherTransport record = await this.OtherTransportRepository.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.DalOtherTransportMapper.MapEntityToModel(record));
            }
        }
Пример #9
0
        public void MapEntityToModelList()
        {
            var            mapper = new DALOtherTransportMapper();
            OtherTransport item   = new OtherTransport();

            item.SetProperties(1, 1, 1);
            List <ApiOtherTransportServerResponseModel> response = mapper.MapEntityToModel(new List <OtherTransport>()
            {
                { item }
            });

            response.Count.Should().Be(1);
        }
Пример #10
0
        public void MapEFToBOList()
        {
            var            mapper = new DALOtherTransportMapper();
            OtherTransport entity = new OtherTransport();

            entity.SetProperties(1, 1, 1);

            List <BOOtherTransport> response = mapper.MapEFToBO(new List <OtherTransport>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
Пример #11
0
        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 async void Get()
        {
            var mock   = new ServiceMockFacade <IOtherTransportRepository>();
            var record = new OtherTransport();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new OtherTransportService(mock.LoggerMock.Object,
                                                    mock.RepositoryMock.Object,
                                                    mock.ModelValidatorMockFactory.OtherTransportModelValidatorMock.Object,
                                                    mock.BOLMapperMockFactory.BOLOtherTransportMapperMock,
                                                    mock.DALMapperMockFactory.DALOtherTransportMapperMock);

            ApiOtherTransportResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Пример #13
0
        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));
            }
        }
Пример #14
0
        public virtual ApiOtherTransportServerResponseModel MapEntityToModel(
            OtherTransport item)
        {
            var model = new ApiOtherTransportServerResponseModel();

            model.SetProperties(item.Id,
                                item.HandlerId,
                                item.PipelineStepId);
            if (item.HandlerIdNavigation != null)
            {
                var handlerIdModel = new ApiHandlerServerResponseModel();
                handlerIdModel.SetProperties(
                    item.HandlerIdNavigation.Id,
                    item.HandlerIdNavigation.CountryId,
                    item.HandlerIdNavigation.Email,
                    item.HandlerIdNavigation.FirstName,
                    item.HandlerIdNavigation.LastName,
                    item.HandlerIdNavigation.Phone);

                model.SetHandlerIdNavigation(handlerIdModel);
            }

            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);
        }