Exemplo n.º 1
0
        public virtual CommunityActionTemplate MapBOToEF(
            BOCommunityActionTemplate bo)
        {
            CommunityActionTemplate efCommunityActionTemplate = new CommunityActionTemplate();

            efCommunityActionTemplate.SetProperties(
                bo.ExternalId,
                bo.Id,
                bo.JSON,
                bo.Name);
            return(efCommunityActionTemplate);
        }
Exemplo n.º 2
0
        public virtual BOCommunityActionTemplate MapEFToBO(
            CommunityActionTemplate ef)
        {
            var bo = new BOCommunityActionTemplate();

            bo.SetProperties(
                ef.Id,
                ef.ExternalId,
                ef.JSON,
                ef.Name);
            return(bo);
        }
Exemplo n.º 3
0
        public async Task <ApiCommunityActionTemplateResponseModel> ByName(string name)
        {
            CommunityActionTemplate record = await this.communityActionTemplateRepository.ByName(name);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.bolCommunityActionTemplateMapper.MapBOToModel(this.dalCommunityActionTemplateMapper.MapEFToBO(record)));
            }
        }
Exemplo n.º 4
0
        public async Task <ApiCommunityActionTemplateResponseModel> ByExternalId(Guid externalId)
        {
            CommunityActionTemplate record = await this.communityActionTemplateRepository.ByExternalId(externalId);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.bolCommunityActionTemplateMapper.MapBOToModel(this.dalCommunityActionTemplateMapper.MapEFToBO(record)));
            }
        }
        private async Task <bool> BeUniqueByName(ApiCommunityActionTemplateRequestModel model, CancellationToken cancellationToken)
        {
            CommunityActionTemplate record = await this.communityActionTemplateRepository.ByName(model.Name);

            if (record == null || (this.existingRecordId != default(string) && record.Id == this.existingRecordId))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        public void MapEFToBOList()
        {
            var mapper = new DALCommunityActionTemplateMapper();
            CommunityActionTemplate entity = new CommunityActionTemplate();

            entity.SetProperties(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", "A", "A");

            List <BOCommunityActionTemplate> response = mapper.MapEFToBO(new List <CommunityActionTemplate>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
Exemplo n.º 7
0
        public void MapEFToBO()
        {
            var mapper = new DALCommunityActionTemplateMapper();
            CommunityActionTemplate entity = new CommunityActionTemplate();

            entity.SetProperties(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", "A", "A");

            BOCommunityActionTemplate response = mapper.MapEFToBO(entity);

            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Id.Should().Be("A");
            response.JSON.Should().Be("A");
            response.Name.Should().Be("A");
        }
Exemplo n.º 8
0
        public void MapBOToEF()
        {
            var mapper = new DALCommunityActionTemplateMapper();
            var bo     = new BOCommunityActionTemplate();

            bo.SetProperties("A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", "A");

            CommunityActionTemplate response = mapper.MapBOToEF(bo);

            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Id.Should().Be("A");
            response.JSON.Should().Be("A");
            response.Name.Should().Be("A");
        }
        public async void Get()
        {
            var mock   = new ServiceMockFacade <ICommunityActionTemplateRepository>();
            var record = new CommunityActionTemplate();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(record));
            var service = new CommunityActionTemplateService(mock.LoggerMock.Object,
                                                             mock.RepositoryMock.Object,
                                                             mock.ModelValidatorMockFactory.CommunityActionTemplateModelValidatorMock.Object,
                                                             mock.BOLMapperMockFactory.BOLCommunityActionTemplateMapperMock,
                                                             mock.DALMapperMockFactory.DALCommunityActionTemplateMapperMock);

            ApiCommunityActionTemplateResponseModel response = await service.Get(default(string));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>()));
        }