Created
September 21, 2017 20:57
-
-
Save dariuszparzygnat/3a0b226061f7e99804f58d119d336a52 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
using System.Collections.Generic; | |
using System.Linq; | |
using AutomapperConfiguration.AutoMapperConfig; | |
using AutoMapper; | |
namespace AutomapperConfiguration | |
{ | |
public class PeopleService | |
{ | |
private readonly IMapper _mapper; | |
private readonly IEnumerable<Person> _people; | |
public PeopleService(IEnumerable<Person> people, IAutoMapperConfiguration autoMapperConfiguration) | |
{ | |
_people = people; | |
_mapper = autoMapperConfiguration.Configure().CreateMapper(); | |
} | |
public IList<NewsletterDto> GetPeopleForNewsletter() | |
{ | |
var peopleAssignedToNewsletter = _people.Where(e => e.AssignedToNewsletter); | |
var result = _mapper.Map<IEnumerable<Person>, IList<NewsletterDto>>(peopleAssignedToNewsletter); | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment