forked from JoergEg/CQRS-Sample
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WPF Client: create customer, show customer details, customer relocati…
…ng, screen for choosing next task
- Loading branch information
JoergEg
committed
Mar 11, 2011
1 parent
317d77c
commit f1474b5
Showing
28 changed files
with
8,159 additions
and
75 deletions.
There are no files selected for viewing
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
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
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
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
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
22 changes: 22 additions & 0 deletions
22
CQRSSample.WpfClient/ApplicationFramework/Converters/CollapsedWhenNullConverter.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace CQRSSample.WpfClient.ApplicationFramework.Converters | ||
{ | ||
public class CollapsedWhenNullConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return value == null | ||
? Visibility.Collapsed | ||
: Visibility.Visible; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
CQRSSample.WpfClient/ApplicationFramework/Resources/ConverterResource.xaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:Converters="clr-namespace:CQRSSample.WpfClient.ApplicationFramework.Converters"> | ||
|
||
<Converters:CollapsedWhenNullConverter x:Key="collapsedWhenNullConverter" /> | ||
|
||
</ResourceDictionary> |
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
14 changes: 14 additions & 0 deletions
14
CQRSSample.WpfClient/Modules/CustomerDetails/CreateCustomer/CreateCustomerView.xaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<UserControl x:Class="CQRSSample.WpfClient.Modules.CustomerDetails.CreateCustomer.CreateCustomerView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
mc:Ignorable="d" | ||
d:DesignHeight="800" d:DesignWidth="600"> | ||
<StackPanel HorizontalAlignment="Left"> | ||
<TextBlock>Customer name:</TextBlock> | ||
<TextBox Text="{Binding Command.CustomerName, UpdateSourceTrigger=PropertyChanged}" Width="400" /> | ||
|
||
<Button x:Name="Save" Content="Save" Margin="0 20 0 0" Width="100" HorizontalAlignment="Right" IsDefault="True" /> | ||
</StackPanel> | ||
</UserControl> |
27 changes: 27 additions & 0 deletions
27
CQRSSample.WpfClient/Modules/CustomerDetails/CreateCustomer/CreateCustomerView.xaml.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace CQRSSample.WpfClient.Modules.CustomerDetails.CreateCustomer | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CreateCustomerView.xaml | ||
/// </summary> | ||
public partial class CreateCustomerView : UserControl | ||
{ | ||
public CreateCustomerView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
CQRSSample.WpfClient/Modules/CustomerDetails/CreateCustomer/CreateCustomerViewModel.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using Caliburn.Micro; | ||
using CQRSSample.Domain.Commands; | ||
using CQRSSample.Infrastructure; | ||
|
||
namespace CQRSSample.WpfClient.Modules.CustomerDetails.CreateCustomer | ||
{ | ||
public class CreateCustomerViewModel : Screen | ||
{ | ||
private readonly IBus _bus; | ||
private readonly IEventAggregator _eventAggregator; | ||
|
||
public CreateCustomerViewModel(IBus bus, IEventAggregator eventAggregator) | ||
{ | ||
_bus = bus; | ||
_eventAggregator = eventAggregator; | ||
Command = new CreateCustomerCommand(Guid.NewGuid()); | ||
} | ||
|
||
public CreateCustomerCommand Command{ get; private set; } | ||
|
||
public void Save() | ||
{ | ||
//important: send command over bus | ||
_bus.Send(Command); | ||
|
||
//signal for UI - change view | ||
_eventAggregator.Publish(new CreateCustomerSavedEvent()); | ||
} | ||
} | ||
|
||
public class CreateCustomerSavedEvent | ||
{ | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...pfClient/Modules/CustomerDetails/CustomerDetailsOverview/CustomerDetailsOverviewView.xaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<UserControl x:Class="CQRSSample.WpfClient.Modules.CustomerDetails.CustomerDetailsOverview.CustomerDetailsOverviewView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
mc:Ignorable="d" | ||
d:DesignHeight="800" d:DesignWidth="600"> | ||
<StackPanel HorizontalAlignment="Center"> | ||
<StackPanel VerticalAlignment="Center" Margin="0 0 0 20"> | ||
<TextBlock FontSize="40" FontWeight="ExtraLight" Text="{Binding ViewModel.Name}" /> | ||
<TextBlock HorizontalAlignment="Right" FontWeight="ExtraLight">All you want to know about your cusomter</TextBlock> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Margin="0 0 2 0">Now living in</TextBlock> | ||
<TextBlock Text="{Binding ViewModel.City}"></TextBlock> | ||
</StackPanel> | ||
<Button x:Name="RelocateCustomer" Width="200" Margin="0 20 0 0">Customer relocated</Button> | ||
</StackPanel> | ||
</UserControl> |
27 changes: 27 additions & 0 deletions
27
...lient/Modules/CustomerDetails/CustomerDetailsOverview/CustomerDetailsOverviewView.xaml.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace CQRSSample.WpfClient.Modules.CustomerDetails.CustomerDetailsOverview | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CustomerDetailsOverviewView.xaml | ||
/// </summary> | ||
public partial class CustomerDetailsOverviewView : UserControl | ||
{ | ||
public CustomerDetailsOverviewView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...lient/Modules/CustomerDetails/CustomerDetailsOverview/CustomerDetailsOverviewViewModel.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using Caliburn.Micro; | ||
using CQRSSample.ReadModel; | ||
|
||
namespace CQRSSample.WpfClient.Modules.CustomerDetails.CustomerDetailsOverview | ||
{ | ||
public class CustomerDetailsOverviewViewModel : Screen | ||
{ | ||
private readonly IReadRepository _readRepository; | ||
private readonly IEventAggregator _eventAggregator; | ||
|
||
public CustomerDetailsOverviewViewModel(IReadRepository readRepository, IEventAggregator eventAggregator) | ||
{ | ||
_readRepository = readRepository; | ||
_eventAggregator = eventAggregator; | ||
} | ||
|
||
public void WithCustomer(Guid customerId) | ||
{ | ||
ViewModel = _readRepository.GetById<CustomerListDto>(customerId); | ||
} | ||
|
||
//TODO: Change CustomerListDto to something specific for this screen | ||
public CustomerListDto ViewModel { get; private set; } | ||
|
||
public void RelocateCustomer() | ||
{ | ||
_eventAggregator.Publish(new ShowCustomerRelocatingEvent(ViewModel.Id)); | ||
} | ||
} | ||
|
||
public class ShowCustomerRelocatingEvent | ||
{ | ||
public readonly Guid CustomerId; | ||
|
||
public ShowCustomerRelocatingEvent(Guid customerId) | ||
{ | ||
CustomerId = customerId; | ||
} | ||
} | ||
} |
Oops, something went wrong.