public async Task <bool> HandleAsync(UpdateMenuItemRequest message, IOutputPort <ServiceResponse> outputPort) { var response = await _menuItemRepository.UpdateMenuItem(message.Id, message.ClientSideId, message.Label, message.DisplayOrder); outputPort.Handle(response.Success ? new ServiceResponse(response.Id, true) : new ServiceResponse(response.Errors.Select(e => e.Description))); return(response.Success); }
private async void DoneEditing(object sender, RoutedEventArgs e) { if (Editing == true) { var successfulUpdateMenuItemRequest = await UpdateMenuItemRequest.SendUpdateMenuItemRequest(SelectedMenuItem._id, uxDisplayCategoryEntry.Text, Convert.ToDouble(uxDisplayPriceEntry.Text), uxDisplayNameEntry.Text, NutritionText, DescriptionText); if (successfulUpdateMenuItemRequest) { ContentDialog responseAlert = new ContentDialog { Title = "Successful", Content = "Menu Item has been updated successfully", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } else { ContentDialog responseAlert = new ContentDialog { Title = "Unsuccessful", Content = "Menu Item has not been updated successfully", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } Editing = false; } if (Creating == true) { if (Ingredients.Count == 0 || String.IsNullOrEmpty(uxDisplayNameEntry.Text) || String.IsNullOrEmpty(Picture) || String.IsNullOrEmpty(uxDisplayPriceEntry.Text) || String.IsNullOrEmpty(NutritionText) || String.IsNullOrEmpty(uxDisplayCategoryEntry.Text)) { ContentDialog responseAlert = new ContentDialog { Title = "Unsufficient Data", Content = "Make sure that all of the data fields have been filled out", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); return; } var successfulAddMenuItemRequest = await AddMenuItemRequest.SendAddMenuItemRequest(Ingredients, uxDisplayNameEntry.Text, Picture, DescriptionText, Convert.ToDouble(uxDisplayPriceEntry.Text), NutritionText, uxDisplayCategoryEntry.Text, uxDisplayCategoryEntry.Text); if (successfulAddMenuItemRequest) { ContentDialog responseAlert = new ContentDialog { Title = "Successful", Content = "Menu Item has been added to the server successfully", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } else { ContentDialog responseAlert = new ContentDialog { Title = "Unsuccessful", Content = "Menu Item has not been added successfully. Check that image size is under 50 KB", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } } DisplayMode(); uxMenuPopup.IsOpen = false; RefreshMenuItemList(); }