summaryrefslogtreecommitdiff
path: root/product/client/server/handlers/SaveNewAccountCommand.cs
blob: 5be7f7eb25f13e73b543517d8dbf51a01373b6f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using presentation.windows.common;
using presentation.windows.common.messages;
using presentation.windows.server.domain.accounting;
using presentation.windows.server.orm;

namespace presentation.windows.server.handlers
{
    public class SaveNewAccountCommand : AbstractHandler<CreateNewAccount>
    {
        AccountRepository accounts;
        ServiceBus bus;

        public SaveNewAccountCommand(AccountRepository accounts, ServiceBus bus)
        {
            this.accounts = accounts;
            this.bus = bus;
        }

        public override void handle(CreateNewAccount item)
        {
            accounts.save(Account.New(item.account_name, Currency.named(item.currency)));
            bus.publish<NewAccountCreated>(x => x.name = item.account_name);
        }
    }
}