public bool TryParseNavigation(LaunchActivatedEventArgs e, out object parameter) { if (e.TileId.StartsWith(OutcomeCreatePrefix)) { if (e.Arguments.Contains("CategoryKey=")) { string rawGuid = e.Arguments.Substring(e.Arguments.LastIndexOf('=') + 1); Guid guid; if (Guid.TryParse(rawGuid, out guid)) { parameter = new OutcomeParameter(GuidKey.Create(guid, KeyFactory.Empty(typeof(Category)).Type)); } else { parameter = null; return(false); } } else { parameter = new OutcomeParameter(); } return(true); } parameter = null; return(false); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); OutcomeViewModel viewModel = new OutcomeViewModel(navigator, domainFacade); OutcomeParameter parameter = e.Parameter as OutcomeParameter; if (parameter != null) { if (parameter.Amount != null) { viewModel.Amount = (float)parameter.Amount.Value; } if (parameter.Description != null) { viewModel.Description = parameter.Description; } if (!parameter.CategoryKey.IsEmpty) { viewModel.SelectedCategories.Add(parameter.CategoryKey); } } IEnumerable <CategoryModel> categories = await queryDispatcher.QueryAsync(new ListAllCategory()); viewModel.Categories.AddRange(categories); DataContext = viewModel; }
public async Task ShowAsync(object context) { OutcomeParameter parameter = (OutcomeParameter)context; decimal amount = 0; string currency = null; string description = String.Empty; DateTime when = DateTime.Now; IKey categoryKey = parameter.CategoryKey; // Initiate categories loading... CategoryPicker categoryDialog = new CategoryPicker(); OutcomeAmount amountDialog = new OutcomeAmount(queryDispatcher); amountDialog.PrimaryButtonText = "Next"; if (parameter.CategoryKey.IsEmpty) { amountDialog.SecondaryButtonText = String.Empty; } else { amountDialog.SecondaryButtonText = "Create today"; } if (parameter.Amount != null) { amountDialog.Value = parameter.Amount.Value; amountDialog.Currency = parameter.Amount.Currency; } ContentDialogResult result = await amountDialog.ShowAsync(false); amount = amountDialog.Value; currency = amountDialog.Currency; if (result == ContentDialogResult.Primary) { categoryDialog.PrimaryButtonText = "Next"; categoryDialog.SecondaryButtonText = "Create today"; if (!parameter.CategoryKey.IsEmpty) { categoryDialog.SelectedKey = parameter.CategoryKey; } result = await categoryDialog.ShowAsync(); if (result == ContentDialogResult.None) { return; } categoryKey = categoryDialog.SelectedKey; if (result == ContentDialogResult.Primary) { OutcomeDescription descriptionDialog = new OutcomeDescription(); descriptionDialog.PrimaryButtonText = "Next"; descriptionDialog.SecondaryButtonText = "Create today"; result = await descriptionDialog.ShowAsync(); if (result == ContentDialogResult.None && !descriptionDialog.IsEnterPressed) { return; } description = descriptionDialog.Value; if (result == ContentDialogResult.Primary || descriptionDialog.IsEnterPressed) { OutcomeWhen whenDialog = new OutcomeWhen(); whenDialog.PrimaryButtonText = "Create"; whenDialog.SecondaryButtonText = "Cancel"; whenDialog.Value = when; result = await whenDialog.ShowAsync(); if (result != ContentDialogResult.Primary) { return; } when = whenDialog.Value; } } } await commandDispatcher.HandleAsync(new CreateOutcome( new Price(amount, currency), description, when, categoryKey )); //OutcomeCreatedGuidePost nextDialog = new OutcomeCreatedGuidePost(); //await nextDialog.ShowAsync(); }
public async Task ShowAsync(object context) { OutcomeParameter parameter = (OutcomeParameter)context; decimal amount = 0; string description = String.Empty; DateTime when = DateTime.Now; IKey categoryKey = parameter.CategoryKey; OutcomeAmount amountDialog = new OutcomeAmount(); amountDialog.PrimaryButtonText = "Next"; if (parameter.CategoryKey.IsEmpty) { amountDialog.SecondaryButtonText = String.Empty; } else { amountDialog.SecondaryButtonText = "Create today"; } if (parameter.Amount != null) { amountDialog.Value = (double)parameter.Amount.Value; } ContentDialogResult result = await amountDialog.ShowAsync(); if (result == ContentDialogResult.None) { return; } amount = (decimal)amountDialog.Value; if (result == ContentDialogResult.Primary) { OutcomeDescription descriptionDialog = new OutcomeDescription(); descriptionDialog.PrimaryButtonText = "Next"; if (parameter.CategoryKey.IsEmpty) { descriptionDialog.SecondaryButtonText = String.Empty; } else { descriptionDialog.SecondaryButtonText = "Create today"; } result = await descriptionDialog.ShowAsync(); if (result == ContentDialogResult.None && !descriptionDialog.IsEnterPressed) { return; } description = descriptionDialog.Value; if (result == ContentDialogResult.Primary || descriptionDialog.IsEnterPressed) { CategoryPicker categoryDialog = new CategoryPicker(); categoryDialog.PrimaryButtonText = "Next"; categoryDialog.SecondaryButtonText = "Create today"; if (!parameter.CategoryKey.IsEmpty) { categoryDialog.SelectedKey = parameter.CategoryKey; } result = await categoryDialog.ShowAsync(); if (result == ContentDialogResult.None) { return; } categoryKey = categoryDialog.SelectedKey; if (result == ContentDialogResult.Primary) { OutcomeWhen whenDialog = new OutcomeWhen(); whenDialog.PrimaryButtonText = "Create"; whenDialog.SecondaryButtonText = "Cancel"; whenDialog.Value = when; result = await whenDialog.ShowAsync(); if (result != ContentDialogResult.Primary) { return; } when = whenDialog.Value; } } } await domainFacade.CreateOutcomeAsync( domainFacade.PriceFactory.Create(amount), description, when, categoryKey ); //OutcomeCreatedGuidePost nextDialog = new OutcomeCreatedGuidePost(); //await nextDialog.ShowAsync(); }
public CreateOutcomeCommand(INavigator navigator, OutcomeParameter parameter) : base(navigator, parameter) { }