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"); }
public virtual ApiPostHistoryTypeServerResponseModel MapEntityToModel( PostHistoryType item) { var model = new ApiPostHistoryTypeServerResponseModel(); model.SetProperties(item.Id, item.RwType); return(model); }
public virtual BOPostHistoryType MapEFToBO( PostHistoryType ef) { var bo = new BOPostHistoryType(); bo.SetProperties( ef.Id, ef.Type); return(bo); }
public virtual PostHistoryType MapBOToEF( BOPostHistoryType bo) { PostHistoryType efPostHistoryType = new PostHistoryType(); efPostHistoryType.SetProperties( bo.Id, bo.Type); return(efPostHistoryType); }
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"); }
public virtual PostHistoryType MapModelToEntity( int id, ApiPostHistoryTypeServerRequestModel model ) { PostHistoryType item = new PostHistoryType(); item.SetProperties( id, model.RwType); return(item); }
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"); }
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"); }
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)); } }
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); }
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); }
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); }
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>())); }
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)); } }