fix bugs
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
e25a1042b2
commit
629d2f3cb1
@ -1,82 +1,84 @@
|
|||||||
using Services;
|
using Services;
|
||||||
using Services;
|
using Models;
|
||||||
using Models;
|
using ShoopNCook.Views;
|
||||||
using ShoopNCook.Views;
|
|
||||||
|
namespace ShoopNCook.Pages;
|
||||||
namespace ShoopNCook.Pages;
|
|
||||||
|
public partial class MyRecipesPage : ContentPage
|
||||||
public partial class MyRecipesPage : ContentPage
|
{
|
||||||
{
|
|
||||||
|
private IRecipesService service;
|
||||||
private IRecipesService service;
|
private Account account;
|
||||||
private Account account;
|
|
||||||
|
public MyRecipesPage(Account account, IRecipesService service)
|
||||||
public MyRecipesPage(
|
{
|
||||||
Account account,
|
InitializeComponent();
|
||||||
IRecipesService service)
|
|
||||||
{
|
this.service = service;
|
||||||
InitializeComponent();
|
this.account = account;
|
||||||
|
|
||||||
this.service = service;
|
service
|
||||||
this.account = account;
|
.GetRecipesOf(account)
|
||||||
|
.GetAccountRecipes()
|
||||||
service
|
.ForEach(AddRecipeView);
|
||||||
.GetRecipesOf(account)
|
}
|
||||||
.GetAccountRecipes()
|
|
||||||
.ForEach(AddRecipeView);
|
private void AddRecipeView(RecipeInfo info)
|
||||||
}
|
{
|
||||||
|
RecipesLayout.Children.Add(new OwnedRecipeView(info, () =>
|
||||||
private void AddRecipeView(RecipeInfo info)
|
{
|
||||||
{
|
Recipe? recipe = service.GetRecipe(info);
|
||||||
RecipesLayout.Children.Add(new OwnedRecipeView(info, () =>
|
if (recipe == null)
|
||||||
{
|
{
|
||||||
Recipe recipe = service.GetRecipe(info);
|
UserNotifier.Error("Could not find recipe");
|
||||||
IAccountRecipesPreferencesService preferences = service.GetPreferencesOf(account);
|
return;
|
||||||
Shell.Current.Navigation.PushAsync(new RecipePage(recipe, preferences, 1));
|
}
|
||||||
},
|
IAccountRecipesPreferencesService preferences = service.GetPreferencesOf(account);
|
||||||
() => RemoveRecipe(info)
|
Shell.Current.Navigation.PushAsync(new RecipePage(recipe, preferences, 1));
|
||||||
));
|
},
|
||||||
}
|
() => RemoveRecipe(info)
|
||||||
|
));
|
||||||
private void RemoveRecipe(RecipeInfo info)
|
}
|
||||||
{
|
|
||||||
IAccountOwnedRecipesService recipes = service.GetRecipesOf(account);
|
private void RemoveRecipe(RecipeInfo info)
|
||||||
|
{
|
||||||
if (!recipes.RemoveRecipe(info))
|
IAccountOwnedRecipesService recipes = service.GetRecipesOf(account);
|
||||||
{
|
|
||||||
UserNotifier.Error("Could not remove recipe");
|
if (!recipes.RemoveRecipe(info))
|
||||||
return;
|
{
|
||||||
}
|
UserNotifier.Error("Could not remove recipe");
|
||||||
foreach (OwnedRecipeView view in RecipesLayout.Children)
|
return;
|
||||||
{
|
}
|
||||||
if (view.IsViewing(info))
|
foreach (OwnedRecipeView view in RecipesLayout.Children)
|
||||||
{
|
{
|
||||||
RecipesLayout.Remove(view);
|
if (view.IsViewing(info))
|
||||||
break;
|
{
|
||||||
}
|
RecipesLayout.Remove(view);
|
||||||
}
|
break;
|
||||||
UserNotifier.Success("Recipe successfully removed");
|
}
|
||||||
}
|
}
|
||||||
|
UserNotifier.Success("Recipe successfully removed");
|
||||||
private async void OnBackButtonClicked(object sender, EventArgs e)
|
}
|
||||||
{
|
|
||||||
await Navigation.PopAsync();
|
private async void OnBackButtonClicked(object sender, EventArgs e)
|
||||||
}
|
{
|
||||||
private async void OnAddRecipeButtonClicked(object sender, EventArgs e)
|
await Navigation.PopAsync();
|
||||||
{
|
}
|
||||||
IAccountOwnedRecipesService recipes = service.GetRecipesOf(account);
|
private async void OnAddRecipeButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
var page = new CreateRecipePage(account.User, recipe =>
|
IAccountOwnedRecipesService recipes = service.GetRecipesOf(account);
|
||||||
{
|
|
||||||
if (!recipes.UploadRecipe(recipe))
|
var page = new CreateRecipePage(account.User, recipe =>
|
||||||
{
|
{
|
||||||
UserNotifier.Error("Could not upload recipe.");
|
if (!recipes.UploadRecipe(recipe))
|
||||||
return;
|
{
|
||||||
}
|
UserNotifier.Error("Could not upload recipe.");
|
||||||
UserNotifier.Success("Recipe Successfuly uploaded !");
|
return;
|
||||||
AddRecipeView(recipe.Info);
|
}
|
||||||
Shell.Current.Navigation.PopAsync(); //go back to current recipe page.
|
UserNotifier.Success("Recipe Successfuly uploaded !");
|
||||||
});
|
AddRecipeView(recipe.Info);
|
||||||
Shell.Current.Navigation.PushAsync(page); //display RecipePage editor
|
Shell.Current.Navigation.PopAsync(); //go back to current recipe page.
|
||||||
}
|
});
|
||||||
|
Shell.Current.Navigation.PushAsync(page); //display RecipePage editor
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue