public virtual CountryRequirement MapBOToEF( BOCountryRequirement bo) { CountryRequirement efCountryRequirement = new CountryRequirement(); efCountryRequirement.SetProperties( bo.CountryId, bo.Details, bo.Id); return(efCountryRequirement); }
public virtual BOCountryRequirement MapEFToBO( CountryRequirement ef) { var bo = new BOCountryRequirement(); bo.SetProperties( ef.Id, ef.CountryId, ef.Details); return(bo); }
public void MapModelToEntity() { var mapper = new DALCountryRequirementMapper(); ApiCountryRequirementServerRequestModel model = new ApiCountryRequirementServerRequestModel(); model.SetProperties(1, "A"); CountryRequirement response = mapper.MapModelToEntity(1, model); response.CountryId.Should().Be(1); response.Details.Should().Be("A"); }
public void MapEntityToModel() { var mapper = new DALCountryRequirementMapper(); CountryRequirement item = new CountryRequirement(); item.SetProperties(1, 1, "A"); ApiCountryRequirementServerResponseModel response = mapper.MapEntityToModel(item); response.CountryId.Should().Be(1); response.Details.Should().Be("A"); response.Id.Should().Be(1); }
public virtual async Task <ApiCountryRequirementServerResponseModel> Get(int id) { CountryRequirement record = await this.CountryRequirementRepository.Get(id); if (record == null) { return(null); } else { return(this.DalCountryRequirementMapper.MapEntityToModel(record)); } }
public void MapEFToBO() { var mapper = new DALCountryRequirementMapper(); CountryRequirement entity = new CountryRequirement(); entity.SetProperties(1, "A", 1); BOCountryRequirement response = mapper.MapEFToBO(entity); response.CountryId.Should().Be(1); response.Detail.Should().Be("A"); response.Id.Should().Be(1); }
public void MapBOToEF() { var mapper = new DALCountryRequirementMapper(); var bo = new BOCountryRequirement(); bo.SetProperties(1, 1, "A"); CountryRequirement response = mapper.MapBOToEF(bo); response.CountryId.Should().Be(1); response.Detail.Should().Be("A"); response.Id.Should().Be(1); }
public virtual CountryRequirement MapModelToEntity( int id, ApiCountryRequirementServerRequestModel model ) { CountryRequirement item = new CountryRequirement(); item.SetProperties( id, model.CountryId, model.Details); return(item); }
public void MapEntityToModelList() { var mapper = new DALCountryRequirementMapper(); CountryRequirement item = new CountryRequirement(); item.SetProperties(1, 1, "A"); List <ApiCountryRequirementServerResponseModel> response = mapper.MapEntityToModel(new List <CountryRequirement>() { { item } }); response.Count.Should().Be(1); }
public void MapEFToBOList() { var mapper = new DALCountryRequirementMapper(); CountryRequirement entity = new CountryRequirement(); entity.SetProperties(1, "A", 1); List <BOCountryRequirement> response = mapper.MapEFToBO(new List <CountryRequirement>() { entity }); response.Count.Should().Be(1); }
public virtual async Task <CreateResponse <ApiCountryRequirementServerResponseModel> > Create( ApiCountryRequirementServerRequestModel model) { CreateResponse <ApiCountryRequirementServerResponseModel> response = ValidationResponseFactory <ApiCountryRequirementServerResponseModel> .CreateResponse(await this.CountryRequirementModelValidator.ValidateCreateAsync(model)); if (response.Success) { CountryRequirement record = this.DalCountryRequirementMapper.MapModelToEntity(default(int), model); record = await this.CountryRequirementRepository.Create(record); response.SetRecord(this.DalCountryRequirementMapper.MapEntityToModel(record)); await this.mediator.Publish(new CountryRequirementCreatedNotification(response.Record)); } return(response); }
public async void Get() { var mock = new ServiceMockFacade <ICountryRequirementRepository>(); var record = new CountryRequirement(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new CountryRequirementService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.CountryRequirementModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLCountryRequirementMapperMock, mock.DALMapperMockFactory.DALCountryRequirementMapperMock); ApiCountryRequirementResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public virtual ApiCountryRequirementServerResponseModel MapEntityToModel( CountryRequirement item) { var model = new ApiCountryRequirementServerResponseModel(); model.SetProperties(item.Id, item.CountryId, item.Details); if (item.CountryIdNavigation != null) { var countryIdModel = new ApiCountryServerResponseModel(); countryIdModel.SetProperties( item.CountryIdNavigation.Id, item.CountryIdNavigation.Name); model.SetCountryIdNavigation(countryIdModel); } return(model); }
public virtual async Task <UpdateResponse <ApiCountryRequirementServerResponseModel> > Update( int id, ApiCountryRequirementServerRequestModel model) { var validationResult = await this.CountryRequirementModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { CountryRequirement record = this.DalCountryRequirementMapper.MapModelToEntity(id, model); await this.CountryRequirementRepository.Update(record); record = await this.CountryRequirementRepository.Get(id); ApiCountryRequirementServerResponseModel apiModel = this.DalCountryRequirementMapper.MapEntityToModel(record); await this.mediator.Publish(new CountryRequirementUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiCountryRequirementServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiCountryRequirementServerResponseModel> .UpdateResponse(validationResult)); } }