diff --git a/MCTG/Exception/AppException.csproj b/MCTG/Exception/AppException.csproj
new file mode 100644
index 0000000..4658cbf
--- /dev/null
+++ b/MCTG/Exception/AppException.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+
+
diff --git a/MCTG/Exception/RecipeNotFoundException.cs b/MCTG/Exception/RecipeNotFoundException.cs
new file mode 100644
index 0000000..6fe37c6
--- /dev/null
+++ b/MCTG/Exception/RecipeNotFoundException.cs
@@ -0,0 +1,10 @@
+
+namespace AppException
+{
+ [Serializable]
+ public class RecipeNotFoundException : Exception
+ {
+ public RecipeNotFoundException() : base("Recipe not found.") { }
+ public RecipeNotFoundException(int id) : base($"Recipe id: '{id}'not found.") { }
+ }
+}
diff --git a/MCTG/Exception/UserNotFoundException.cs b/MCTG/Exception/UserNotFoundException.cs
new file mode 100644
index 0000000..602482d
--- /dev/null
+++ b/MCTG/Exception/UserNotFoundException.cs
@@ -0,0 +1,9 @@
+namespace AppException
+{
+ [Serializable]
+ public class UserNotFoundException : Exception
+ {
+ public UserNotFoundException() : base("User not found.") { }
+ public UserNotFoundException(string userMail) : base($"User with mail: '{userMail}' not found.") { }
+ }
+}
diff --git a/MCTG/Managers/Managers.csproj b/MCTG/Managers/Managers.csproj
new file mode 100644
index 0000000..4658cbf
--- /dev/null
+++ b/MCTG/Managers/Managers.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+
+
diff --git a/MCTG/Managers/RecipeDefaultManager.cs b/MCTG/Managers/RecipeDefaultManager.cs
new file mode 100644
index 0000000..09e2599
--- /dev/null
+++ b/MCTG/Managers/RecipeDefaultManager.cs
@@ -0,0 +1,80 @@
+using AppException;
+using Model;
+
+namespace Managers
+{
+ public class RecipeDefaultManager : IRecipeManager
+ {
+ private IDataManager _dataManager;
+
+ public RecipeDefaultManager(IDataManager dataManager)
+ {
+ _dataManager = dataManager;
+ }
+
+ public bool AddRecipeToData(Recipe recipe)
+ {
+ var recipeList = _dataManager.Data[nameof(Recipe)];
+
+ if (recipeList.Exists(r => r.Equals(recipe)))
+ return false;
+
+ _dataManager.Data[nameof(Recipe)].Add(recipe);
+ return true;
+ }
+
+ public RecipeCollection GetAllRecipes()
+ {
+ return new RecipeCollection(
+ "All recipes",
+ _dataManager.GetFromData().ToArray());
+ }
+
+ public RecipeCollection GetRecipeByAuthor(string authorMail)
+ {
+ User? author = _dataManager.GetFromData()
+ .ToList()
+ .Find(u => u.Mail == authorMail);
+ if (author is null)
+ throw new UserNotFoundException(authorMail);
+
+ return new RecipeCollection(
+ $"{author.Name} {author.Surname}'s recipes",
+ _dataManager.GetFromData().ToArray());
+ }
+
+ public RecipeCollection GetRecipeByTitle(string title)
+ {
+ IEnumerable recipes = from Recipe recipe in _dataManager.GetFromData()
+ where recipe.Title.Contains(title)
+ select recipe;
+ return new RecipeCollection(
+ $"Search for '{title}'", recipes.ToArray());
+ }
+
+ public Recipe GetRecipeFromId(int id)
+ {
+ Recipe? recipe = _dataManager.GetFromData()
+ .ToList()
+ .Find(r => r.Id == id);
+ if (recipe is null)
+ throw new RecipeNotFoundException();
+
+ return recipe;
+ }
+
+ public RecipeCollection GetRecipesByPriorityOrder(Priority priority)
+ {
+ IEnumerable recipes = from Recipe recipe in _dataManager.GetFromData()
+ where recipe.Title.Contains(title)
+ select recipe;
+ return new RecipeCollection(
+ $"Suggestions", recipes.ToArray());
+ }
+
+ public bool ModifyRecipeInData(Recipe recipe)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/MCTG/Model/Managers/IDataManager.cs b/MCTG/Model/Managers/IDataManager.cs
index ffb1aee..0e83cda 100644
--- a/MCTG/Model/Managers/IDataManager.cs
+++ b/MCTG/Model/Managers/IDataManager.cs
@@ -1,17 +1,23 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Model.Managers
+namespace Model
{
public interface IDataManager
{
+ IDataSerializer Serializer { get; }
+ Dictionary> Data { get; }
+
void LoadData();
void ReloadData();
void SaveData();
void Import(string pathOfTheFile) where T : class;
void Export(T obj, string pathToExport) where T : class;
+
+ ICollection GetFromData();
}
}
diff --git a/MCTG/Model/Managers/IRecipeManager.cs b/MCTG/Model/Managers/IRecipeManager.cs
index f9d7e00..5ccf642 100644
--- a/MCTG/Model/Managers/IRecipeManager.cs
+++ b/MCTG/Model/Managers/IRecipeManager.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Model.Managers
+namespace Model
{
public interface IRecipeManager
{
diff --git a/MCTG/Model/Managers/IUserManager.cs b/MCTG/Model/Managers/IUserManager.cs
index d86a404..bf5f04f 100644
--- a/MCTG/Model/Managers/IUserManager.cs
+++ b/MCTG/Model/Managers/IUserManager.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Model.Managers
+namespace Model
{
public interface IUserManager
{