Created
January 29, 2018 19:47
-
-
Save ismcagdas/191c8986d69476a072a3d217a75921fb to your computer and use it in GitHub Desktop.
Acme.HeroShop - HeroAppService.cs
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 HeroAppService : HeroShopAppServiceBase, IHeroAppService | |
{ | |
private readonly IRepository<Hero> _heroRepository; | |
private readonly IRepository<HeroCompany> _heroCompanyRepository; | |
public HeroAppService( | |
IRepository<Hero> heroRepository, | |
IRepository<HeroCompany> heroCompanyRepository) | |
{ | |
_heroRepository = heroRepository; | |
_heroCompanyRepository = heroCompanyRepository; | |
} | |
public List<HeroDto> GetHeroes(int? heroCompanyId) | |
{ | |
var heroes = _heroRepository.GetAll() | |
.WhereIf(heroCompanyId.HasValue, hero => hero.HeroCompanyId == heroCompanyId.Value) | |
.OrderBy(h => h.Name) | |
.ToList(); | |
return ObjectMapper.Map<List<HeroDto>>(heroes); | |
} | |
public List<HeroCompanyDto> GetHeroCompanies() | |
{ | |
return ObjectMapper.Map<List<HeroCompanyDto>>( | |
_heroCompanyRepository.GetAllList() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment