You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
871 B
44 lines
871 B
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();
|
|
}
|
|
|
|
}
|
|
}
|