using Models;
using System.Collections.Generic;
using System.Collections.Immutable;

namespace LocalEndpoint
{

    //Simple class to simulate a recipe database
    internal class RecipesDatabase
    {

        private Dictionary<Guid, Recipe> recipes = new Dictionary<Guid, Recipe>();

        public Recipe? Lookup(Guid id)
        {
            Recipe? recipe;
            recipes.TryGetValue(id, out recipe);
            return recipe;
        }


        public Recipe Get(Guid id)
        {
            return recipes[id];
        }

        public void Insert(Recipe recipe)
        {
            recipes[recipe.Info.Id] = recipe; 
        }

        public void Remove(Guid id)
        {
            recipes.Remove(id);
        }

        public ImmutableList<Recipe> ListAll()
        {
            return recipes.Values.ToImmutableList();
        }

    }
}
