public virtual SpaceFeature MapBOToEF(
            BOSpaceFeature bo)
        {
            SpaceFeature efSpaceFeature = new SpaceFeature();

            efSpaceFeature.SetProperties(
                bo.Id,
                bo.Name);
            return(efSpaceFeature);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALSpaceFeatureMapper();
            ApiSpaceFeatureServerRequestModel model = new ApiSpaceFeatureServerRequestModel();

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

            response.Name.Should().Be("A");
        }
        public virtual BOSpaceFeature MapEFToBO(
            SpaceFeature ef)
        {
            var bo = new BOSpaceFeature();

            bo.SetProperties(
                ef.Id,
                ef.Name);
            return(bo);
        }
        public virtual ApiSpaceFeatureServerResponseModel MapEntityToModel(
            SpaceFeature item)
        {
            var model = new ApiSpaceFeatureServerResponseModel();

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

            return(model);
        }
        public void MapEntityToModel()
        {
            var          mapper = new DALSpaceFeatureMapper();
            SpaceFeature item   = new SpaceFeature();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
        public virtual SpaceFeature MapModelToEntity(
            int id,
            ApiSpaceFeatureServerRequestModel model
            )
        {
            SpaceFeature item = new SpaceFeature();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
        public void MapEFToBO()
        {
            var          mapper = new DALSpaceFeatureMapper();
            SpaceFeature entity = new SpaceFeature();

            entity.SetProperties(1, "A");

            BOSpaceFeature response = mapper.MapEFToBO(entity);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
        public void MapBOToEF()
        {
            var mapper = new DALSpaceFeatureMapper();
            var bo     = new BOSpaceFeature();

            bo.SetProperties(1, "A");

            SpaceFeature response = mapper.MapBOToEF(bo);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
        public virtual async Task <ApiSpaceFeatureServerResponseModel> Get(int id)
        {
            SpaceFeature record = await this.SpaceFeatureRepository.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.DalSpaceFeatureMapper.MapEntityToModel(record));
            }
        }
        public void MapEntityToModelList()
        {
            var          mapper = new DALSpaceFeatureMapper();
            SpaceFeature item   = new SpaceFeature();

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

            response.Count.Should().Be(1);
        }
Example #11
0
        public void MapEFToBOList()
        {
            var          mapper = new DALSpaceFeatureMapper();
            SpaceFeature entity = new SpaceFeature();

            entity.SetProperties(1, "A", 1);

            List <BOSpaceFeature> response = mapper.MapEFToBO(new List <SpaceFeature>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
Example #12
0
        public virtual async Task <CreateResponse <ApiSpaceFeatureServerResponseModel> > Create(
            ApiSpaceFeatureServerRequestModel model)
        {
            CreateResponse <ApiSpaceFeatureServerResponseModel> response = ValidationResponseFactory <ApiSpaceFeatureServerResponseModel> .CreateResponse(await this.SpaceFeatureModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                SpaceFeature record = this.DalSpaceFeatureMapper.MapModelToEntity(default(int), model);
                record = await this.SpaceFeatureRepository.Create(record);

                response.SetRecord(this.DalSpaceFeatureMapper.MapEntityToModel(record));
                await this.mediator.Publish(new SpaceFeatureCreatedNotification(response.Record));
            }

            return(response);
        }
        public async void Get()
        {
            var mock   = new ServiceMockFacade <ISpaceFeatureRepository>();
            var record = new SpaceFeature();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new SpaceFeatureService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.SpaceFeatureModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLSpaceFeatureMapperMock,
                                                  mock.DALMapperMockFactory.DALSpaceFeatureMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Example #14
0
        public virtual async Task <UpdateResponse <ApiSpaceFeatureServerResponseModel> > Update(
            int id,
            ApiSpaceFeatureServerRequestModel model)
        {
            var validationResult = await this.SpaceFeatureModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                SpaceFeature record = this.DalSpaceFeatureMapper.MapModelToEntity(id, model);
                await this.SpaceFeatureRepository.Update(record);

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

                ApiSpaceFeatureServerResponseModel apiModel = this.DalSpaceFeatureMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SpaceFeatureUpdatedNotification(apiModel));

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