main
1using System;
2using Gorilla.Commons.Utility;
3using presentation.windows.common;
4using presentation.windows.common.messages;
5
6namespace presentation.windows.presenters
7{
8 public class AddFamilyMemberPresenter : DialogPresenter
9 {
10 UICommandBuilder ui_builder;
11
12 public AddFamilyMemberPresenter(UICommandBuilder ui_builder)
13 {
14 this.ui_builder = ui_builder;
15 }
16
17 public void present()
18 {
19 Save = ui_builder.build<SaveCommand>(this);
20 Cancel = ui_builder.build<CancelCommand>(this);
21 date_of_birth = Clock.today();
22 }
23
24 public string first_name { get; set; }
25 public string last_name { get; set; }
26 public DateTime date_of_birth { get; set; }
27 public IObservableCommand Save { get; set; }
28 public IObservableCommand Cancel { get; set; }
29 public Action close { get; set; }
30
31 public class SaveCommand : UICommand<AddFamilyMemberPresenter>
32 {
33 ServiceBus bus;
34
35 public SaveCommand(ServiceBus bus)
36 {
37 this.bus = bus;
38 }
39
40 protected override void run(AddFamilyMemberPresenter presenter)
41 {
42 bus.publish<FamilyMemberToAdd>(x =>
43 {
44 x.first_name = presenter.first_name;
45 x.last_name = presenter.last_name;
46 x.date_of_birth = presenter.date_of_birth;
47 });
48 presenter.close();
49 }
50 }
51 }
52}