|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
@ -12,14 +14,28 @@ namespace Model.Managers
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The Main manager of the model.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class MasterManager
|
|
|
|
|
public class MasterManager : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
#region Attributes & Properties
|
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
|
|
|
|
|
|
private RecipeCollection _recipesInSearch = new RecipeCollection("");
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The currently connected user. 'null' if no user is connected.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public User? CurrentConnectedUser { get; private set; }
|
|
|
|
|
|
|
|
|
|
public RecipeCollection RecipesInSearch
|
|
|
|
|
{
|
|
|
|
|
get => _recipesInSearch;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_recipesInSearch = value;
|
|
|
|
|
OnPropertyChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The collection of all recipes loaded.
|
|
|
|
|
/// </summary>
|
|
|
|
@ -46,6 +62,7 @@ namespace Model.Managers
|
|
|
|
|
DataMgr = new DataManager(dataManager);
|
|
|
|
|
CurrentConnectedUser = null;
|
|
|
|
|
Recipes = DataMgr.GetRecipes("all recipes");
|
|
|
|
|
RecipesInSearch = DataMgr.GetRecipes("search on");
|
|
|
|
|
Users = DataMgr.GetUsers();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
@ -132,6 +149,13 @@ namespace Model.Managers
|
|
|
|
|
public RecipeCollection GetCurrentUserRecipes()
|
|
|
|
|
=> new RecipeCollection("User recipes",
|
|
|
|
|
DataMgr.GetRecipes().FindAll(r => r.AuthorMail == CurrentConnectedUser?.Mail).ToArray());
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Notify property change handler.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="propertyName">the name of the property that change.</param>
|
|
|
|
|
public void OnPropertyChange([CallerMemberName] string propertyName = "")
|
|
|
|
|
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|