Skip to content

Commit

Permalink
Added string parameter to submit order command
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbegega committed Dec 14, 2015
1 parent 5ece0de commit a8a829b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 10 additions & 6 deletions hwstart/RestaurantManager.UniversalWindows/OrderPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@
</Grid.RowDefinitions>
<TextBlock Grid.Row="2" Grid.Column="1" Text="Special Requests:" />
<TextBlock Grid.Row="2" Grid.Column="2" Text="Order Items:" />
<TextBox Grid.Row="3" Grid.Column="1" />
<ListView x:Name="MenuItems" Grid.Row="2" Grid.RowSpan="3" Grid.Column="0" Margin="10" ItemsSource="{Binding MenuItems}" DisplayMemberPath="Title" />
<ListView Grid.Row="3" Grid.RowSpan="2" Grid.Column="2" Margin="10" ItemsSource="{Binding CurrentlySelectedMenuItems}" DisplayMemberPath="Title" />
<Button Content="Add to Order" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="5" Grid.Column="0"
<TextBox Grid.Row="3" Grid.Column="1" x:Name="SpecialRequests" />
<ListView Grid.Row="2" Grid.RowSpan="3" Grid.Column="0" x:Name="MenuItems"
Margin="10" ItemsSource="{Binding MenuItems}" DisplayMemberPath="Title" />
<ListView Grid.Row="3" Grid.RowSpan="2" Grid.Column="2" Margin="10"
ItemsSource="{Binding CurrentlySelectedMenuItems}" DisplayMemberPath="Title" />
<Button Grid.Row="5" Grid.Column="0" Content="Add to Order" HorizontalAlignment="Center" VerticalAlignment="Center"
Command="{Binding AddToOrderCommand}"
CommandParameter="{Binding ElementName=MenuItems, Path=SelectedItem}"/>
<Button Content="Submit Order" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2"
Command="{Binding SubmitOrderCommand}" />
<Button Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" Content="Submit Order"
HorizontalAlignment="Center" VerticalAlignment="Center"
Command="{Binding SubmitOrderCommand}"
CommandParameter="{Binding ElementName=SpecialRequests, Path=Text}"/>
</Grid>
</Page>
6 changes: 4 additions & 2 deletions hwstart/RestaurantManager.ViewModels/OrderDataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class OrderDataViewModel : ViewModel
public OrderDataViewModel()
{
AddToOrderCommand = new DelegateCommand<MenuItem>(AddToSelected);
SubmitOrderCommand = new DelegateCommand<object>(SubmitOrder);
SubmitOrderCommand = new DelegateCommand<string>(SubmitOrder);
}

protected override void OnDataLoaded()
Expand Down Expand Up @@ -66,7 +66,7 @@ private void AddToSelected(MenuItem item)
}
}

private void SubmitOrder(object parameter)
private void SubmitOrder(string parameter)
{
Order order = new Order();

Expand All @@ -80,6 +80,8 @@ private void SubmitOrder(object parameter)
order.Items = new List<MenuItem>();
order.Items.AddRange(this.CurrentlySelectedMenuItems);

order.SpecialRequests = parameter;

base.Repository.Orders.Add(order);
}
}
Expand Down

0 comments on commit a8a829b

Please sign in to comment.