private async void OnAddRecipe() { ANRErrorMsg = null; if (TheSelectedCategory != null) { if (AddRecipeName != null) { try { if (recipeImageURL == string.Empty) { recipeImageURL = _hardcodedImage; } _recipe.Name = AddRecipeName; _recipe.ImageURL = recipeImageURL; _recipe.Description = AddRecipeDescription; _recipe.UserID = _userOnline.ID; _recipe.CategoryID = TheSelectedCategory.ID; await _recipeDataService.AddNewRecipe(_recipe); _recipe.ID = 0; _recipe.Name = null; _recipe.ImageURL = null; _recipe.Description = null; _recipe.UserID = 0; _recipe.CategoryID = 0; } catch (Exception) { ANRErrorMsg = MessageNames.RecipeException; } } else { ANRErrorMsg = MessageNames.RecipeNameValidation; } } else { ANRErrorMsg = MessageNames.RecipeWithoutCategory; } if (ANRErrorMsg == null) { MessagingCenter.Send(this, MessageNames.RecipeAdded); _navigationService.GoBack(); AddRecipeName = null; AddRecipeDescription = null; recipeImageURL = string.Empty; TheSelectedCategory = null; } }
private async void OnSaveRecipe(object obj) { if (SelectedRecipeImage == string.Empty) { SelectedRecipeImage = _hardcodedImage; } _selectedRecipe.Name = SelectedRecipeName; _selectedRecipe.Description = SelectedRecipeDescription; _selectedRecipe.ImageURL = SelectedRecipeImage; await _recipeDataService.AddNewRecipe(_selectedRecipe); IsEditable = true; IsEditVisible = true; IsReadDescriptionVisible = true; IsSaveVisible = false; IsUploadVisible = false; MessagingCenter.Send(this, MessageNames.RecipeUpdate); }