コード例 #1
0
        public void MapModelToEntity()
        {
            var mapper = new DALPostHistoryTypeMapper();
            ApiPostHistoryTypeServerRequestModel model = new ApiPostHistoryTypeServerRequestModel();

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

            response.RwType.Should().Be("A");
        }
コード例 #2
0
        public virtual ApiPostHistoryTypeServerResponseModel MapEntityToModel(
            PostHistoryType item)
        {
            var model = new ApiPostHistoryTypeServerResponseModel();

            model.SetProperties(item.Id,
                                item.RwType);

            return(model);
        }
コード例 #3
0
        public virtual BOPostHistoryType MapEFToBO(
            PostHistoryType ef)
        {
            var bo = new BOPostHistoryType();

            bo.SetProperties(
                ef.Id,
                ef.Type);
            return(bo);
        }
コード例 #4
0
        public virtual PostHistoryType MapBOToEF(
            BOPostHistoryType bo)
        {
            PostHistoryType efPostHistoryType = new PostHistoryType();

            efPostHistoryType.SetProperties(
                bo.Id,
                bo.Type);
            return(efPostHistoryType);
        }
コード例 #5
0
        public void MapEntityToModel()
        {
            var             mapper = new DALPostHistoryTypeMapper();
            PostHistoryType item   = new PostHistoryType();

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

            response.Id.Should().Be(1);
            response.RwType.Should().Be("A");
        }
コード例 #6
0
        public virtual PostHistoryType MapModelToEntity(
            int id,
            ApiPostHistoryTypeServerRequestModel model
            )
        {
            PostHistoryType item = new PostHistoryType();

            item.SetProperties(
                id,
                model.RwType);
            return(item);
        }
コード例 #7
0
        public void MapEFToBO()
        {
            var             mapper = new DALPostHistoryTypeMapper();
            PostHistoryType entity = new PostHistoryType();

            entity.SetProperties(1, "A");

            BOPostHistoryType response = mapper.MapEFToBO(entity);

            response.Id.Should().Be(1);
            response.Type.Should().Be("A");
        }
コード例 #8
0
        public void MapBOToEF()
        {
            var mapper = new DALPostHistoryTypeMapper();
            var bo     = new BOPostHistoryType();

            bo.SetProperties(1, "A");

            PostHistoryType response = mapper.MapBOToEF(bo);

            response.Id.Should().Be(1);
            response.Type.Should().Be("A");
        }
コード例 #9
0
        public virtual async Task <ApiPostHistoryTypeServerResponseModel> Get(int id)
        {
            PostHistoryType record = await this.PostHistoryTypeRepository.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.DalPostHistoryTypeMapper.MapEntityToModel(record));
            }
        }
コード例 #10
0
        public void MapEntityToModelList()
        {
            var             mapper = new DALPostHistoryTypeMapper();
            PostHistoryType item   = new PostHistoryType();

            item.SetProperties(1, "A");
            List <ApiPostHistoryTypeServerResponseModel> response = mapper.MapEntityToModel(new List <PostHistoryType>()
            {
                { item }
            });

            response.Count.Should().Be(1);
        }
コード例 #11
0
        public void MapEFToBOList()
        {
            var             mapper = new DALPostHistoryTypeMapper();
            PostHistoryType entity = new PostHistoryType();

            entity.SetProperties(1, "A");

            List <BOPostHistoryType> response = mapper.MapEFToBO(new List <PostHistoryType>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
コード例 #12
0
        public virtual async Task <CreateResponse <ApiPostHistoryTypeServerResponseModel> > Create(
            ApiPostHistoryTypeServerRequestModel model)
        {
            CreateResponse <ApiPostHistoryTypeServerResponseModel> response = ValidationResponseFactory <ApiPostHistoryTypeServerResponseModel> .CreateResponse(await this.PostHistoryTypeModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                PostHistoryType record = this.DalPostHistoryTypeMapper.MapModelToEntity(default(int), model);
                record = await this.PostHistoryTypeRepository.Create(record);

                response.SetRecord(this.DalPostHistoryTypeMapper.MapEntityToModel(record));
                await this.mediator.Publish(new PostHistoryTypeCreatedNotification(response.Record));
            }

            return(response);
        }
コード例 #13
0
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IPostHistoryTypeRepository>();
            var record = new PostHistoryType();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new PostHistoryTypeService(mock.LoggerMock.Object,
                                                     mock.RepositoryMock.Object,
                                                     mock.ModelValidatorMockFactory.PostHistoryTypeModelValidatorMock.Object,
                                                     mock.BOLMapperMockFactory.BOLPostHistoryTypeMapperMock,
                                                     mock.DALMapperMockFactory.DALPostHistoryTypeMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
コード例 #14
0
        public virtual async Task <UpdateResponse <ApiPostHistoryTypeServerResponseModel> > Update(
            int id,
            ApiPostHistoryTypeServerRequestModel model)
        {
            var validationResult = await this.PostHistoryTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PostHistoryType record = this.DalPostHistoryTypeMapper.MapModelToEntity(id, model);
                await this.PostHistoryTypeRepository.Update(record);

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

                ApiPostHistoryTypeServerResponseModel apiModel = this.DalPostHistoryTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PostHistoryTypeUpdatedNotification(apiModel));

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