main
 1using System.Linq;
 2using gorilla.utility;
 3using solidware.financials.infrastructure;
 4using solidware.financials.messages;
 5using solidware.financials.service.orm;
 6
 7namespace solidware.financials.service.handlers
 8{
 9    public class FindAllIncomeHandler : Handles<FindAllIncome>
10    {
11        PersonRepository people;
12        Mapper mapper;
13        ServiceBus bus;
14
15        public FindAllIncomeHandler(PersonRepository people, Mapper mapper, ServiceBus bus)
16        {
17            this.people = people;
18            this.mapper = mapper;
19            this.bus = bus;
20        }
21
22        public void handle(FindAllIncome item)
23        {
24            people
25                .find_all()
26                .Select(x => new IncomeMessage
27                             {
28                                 PersonId = x.id,
29                                 Amount = x.income_account.balance(),
30                             })
31                .each(x => bus.publish(x));
32        }
33    }
34}