Created
June 4, 2010 19:13
-
-
Save jmarnold/425824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RenderEntityDetailsAction<TEntity, TRequestModel, TDetailsModel> | |
where TEntity : class | |
where TRequestModel : class | |
where TDetailsModel : class | |
{ | |
private readonly IEntityService _entityService; | |
private readonly IMappingRegistry _mappingRegistry; | |
public RenderEntityDetailsAction(IEntityService entityService, IMappingRegistry mappingRegistry) | |
{ | |
_mappingRegistry = mappingRegistry; | |
_entityService = entityService; | |
} | |
public TDetailsModel Get(TRequestModel requestModel) | |
{ | |
var entity = _entityService.Get<TEntity>(requestModel); | |
if (entity == null) | |
{ | |
throw new EntityNotFoundException<TEntity>(string.Format("{0} could not be found.", typeof(TEntity).Name)); | |
} | |
return _mappingRegistry.Map<TEntity, TDetailsModel>(entity); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment