Esempio n. 1
0
        public virtual Clasp MapBOToEF(
            BOClasp bo)
        {
            Clasp efClasp = new Clasp();

            efClasp.SetProperties(
                bo.Id,
                bo.NextChainId,
                bo.PreviousChainId);
            return(efClasp);
        }
Esempio n. 2
0
        public virtual BOClasp MapEFToBO(
            Clasp ef)
        {
            var bo = new BOClasp();

            bo.SetProperties(
                ef.Id,
                ef.NextChainId,
                ef.PreviousChainId);
            return(bo);
        }
Esempio n. 3
0
        public void MapModelToEntity()
        {
            var mapper = new DALClaspMapper();
            ApiClaspServerRequestModel model = new ApiClaspServerRequestModel();

            model.SetProperties(1, 1);
            Clasp response = mapper.MapModelToEntity(1, model);

            response.NextChainId.Should().Be(1);
            response.PreviousChainId.Should().Be(1);
        }
Esempio n. 4
0
        public void MapEntityToModel()
        {
            var   mapper = new DALClaspMapper();
            Clasp item   = new Clasp();

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

            response.Id.Should().Be(1);
            response.NextChainId.Should().Be(1);
            response.PreviousChainId.Should().Be(1);
        }
Esempio n. 5
0
        public virtual async Task <ApiClaspServerResponseModel> Get(int id)
        {
            Clasp record = await this.ClaspRepository.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.DalClaspMapper.MapEntityToModel(record));
            }
        }
Esempio n. 6
0
        public void MapEntityToModelList()
        {
            var   mapper = new DALClaspMapper();
            Clasp item   = new Clasp();

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

            response.Count.Should().Be(1);
        }
Esempio n. 7
0
        public virtual Clasp MapModelToEntity(
            int id,
            ApiClaspServerRequestModel model
            )
        {
            Clasp item = new Clasp();

            item.SetProperties(
                id,
                model.NextChainId,
                model.PreviousChainId);
            return(item);
        }
Esempio n. 8
0
        public void MapEFToBO()
        {
            var   mapper = new DALClaspMapper();
            Clasp entity = new Clasp();

            entity.SetProperties(1, 1, 1);

            BOClasp response = mapper.MapEFToBO(entity);

            response.Id.Should().Be(1);
            response.NextChainId.Should().Be(1);
            response.PreviousChainId.Should().Be(1);
        }
Esempio n. 9
0
        public void MapBOToEF()
        {
            var mapper = new DALClaspMapper();
            var bo     = new BOClasp();

            bo.SetProperties(1, 1, 1);

            Clasp response = mapper.MapBOToEF(bo);

            response.Id.Should().Be(1);
            response.NextChainId.Should().Be(1);
            response.PreviousChainId.Should().Be(1);
        }
Esempio n. 10
0
        public void MapEFToBOList()
        {
            var   mapper = new DALClaspMapper();
            Clasp entity = new Clasp();

            entity.SetProperties(1, 1, 1);

            List <BOClasp> response = mapper.MapEFToBO(new List <Clasp>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
Esempio n. 11
0
        public virtual async Task <CreateResponse <ApiClaspServerResponseModel> > Create(
            ApiClaspServerRequestModel model)
        {
            CreateResponse <ApiClaspServerResponseModel> response = ValidationResponseFactory <ApiClaspServerResponseModel> .CreateResponse(await this.ClaspModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                Clasp record = this.DalClaspMapper.MapModelToEntity(default(int), model);
                record = await this.ClaspRepository.Create(record);

                response.SetRecord(this.DalClaspMapper.MapEntityToModel(record));
                await this.mediator.Publish(new ClaspCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 12
0
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IClaspRepository>();
            var record = new Clasp();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new ClaspService(mock.LoggerMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ClaspModelValidatorMock.Object,
                                           mock.BOLMapperMockFactory.BOLClaspMapperMock,
                                           mock.DALMapperMockFactory.DALClaspMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Esempio n. 13
0
        public virtual async Task <UpdateResponse <ApiClaspServerResponseModel> > Update(
            int id,
            ApiClaspServerRequestModel model)
        {
            var validationResult = await this.ClaspModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Clasp record = this.DalClaspMapper.MapModelToEntity(id, model);
                await this.ClaspRepository.Update(record);

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

                ApiClaspServerResponseModel apiModel = this.DalClaspMapper.MapEntityToModel(record);
                await this.mediator.Publish(new ClaspUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiClaspServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiClaspServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Esempio n. 14
0
        public virtual ApiClaspServerResponseModel MapEntityToModel(
            Clasp item)
        {
            var model = new ApiClaspServerResponseModel();

            model.SetProperties(item.Id,
                                item.NextChainId,
                                item.PreviousChainId);
            if (item.NextChainIdNavigation != null)
            {
                var nextChainIdModel = new ApiChainServerResponseModel();
                nextChainIdModel.SetProperties(
                    item.NextChainIdNavigation.Id,
                    item.NextChainIdNavigation.ChainStatusId,
                    item.NextChainIdNavigation.ExternalId,
                    item.NextChainIdNavigation.Name,
                    item.NextChainIdNavigation.TeamId);

                model.SetNextChainIdNavigation(nextChainIdModel);
            }

            if (item.PreviousChainIdNavigation != null)
            {
                var previousChainIdModel = new ApiChainServerResponseModel();
                previousChainIdModel.SetProperties(
                    item.PreviousChainIdNavigation.Id,
                    item.PreviousChainIdNavigation.ChainStatusId,
                    item.PreviousChainIdNavigation.ExternalId,
                    item.PreviousChainIdNavigation.Name,
                    item.PreviousChainIdNavigation.TeamId);

                model.SetPreviousChainIdNavigation(previousChainIdModel);
            }

            return(model);
        }