main
 1using System;
 2using System.Collections.Generic;
 3using presentation.windows.common;
 4
 5namespace presentation.windows.presenters
 6{
 7    public class AddNewDetailAccountPresenter : DialogPresenter
 8    {
 9        UICommandBuilder builder;
10
11        public AddNewDetailAccountPresenter(UICommandBuilder builder)
12        {
13            this.builder = builder;
14        }
15
16        public void present()
17        {
18            add = builder.build<CreateNewAccount>(this);
19            cancel = builder.build<CancelCommand>(this);
20            currencies = new[] { "CAD" }.to_observable();
21        }
22
23        public string account_name { get; set; }
24        public string currency { get; set; }
25        public IEnumerable<string> currencies { get; set; }
26        public Action close { get; set; }
27        public IObservableCommand add { get; set; }
28        public IObservableCommand cancel { get; set; }
29
30        public class CreateNewAccount : UICommand<AddNewDetailAccountPresenter>
31        {
32            ServiceBus bus;
33
34            public CreateNewAccount(ServiceBus bus)
35            {
36                this.bus = bus;
37            }
38
39            protected override void run(AddNewDetailAccountPresenter presenter)
40            {
41                bus.publish<common.messages.CreateNewDetailAccountCommand>(x =>
42                {
43                    x.account_name = presenter.account_name;
44                    x.currency = presenter.currency;
45                });
46                presenter.close();
47            }
48        }
49    }
50}