Ejemplo n.º 1
0
    /// <inheritdoc />
    public ExistingIngredientDto CreateIngredient(NewIngredientDto newIngredientDto)
    {
        var newIngredient     = Mapper.Map <Ingredient>(newIngredientDto);
        var createdIngredient = IngredientDbAccess.AddIngredient(newIngredient);

        return(Mapper.Map <ExistingIngredientDto>(createdIngredient));
    }
Ejemplo n.º 2
0
    public void CreateIngredient()
    {
        using var inMemoryDbContext = new InMemoryDbContext();
        var vegetables = new ArticleGroup("Vegetables");
        var tomato     = new Article {
            Name = "Tomato", ArticleGroup = vegetables, IsInventory = false
        };
        var piece = new Unit("Piece");

        inMemoryDbContext.ArticleGroups.Add(vegetables);
        inMemoryDbContext.Articles.Add(tomato);
        inMemoryDbContext.Units.Add(piece);
        inMemoryDbContext.SaveChanges();
        var testee = new IngredientDbAccess(inMemoryDbContext);

        var result = testee.AddIngredient(new Ingredient(tomato, 2, piece));

        inMemoryDbContext.SaveChanges();

        inMemoryDbContext.Ingredients.Should().Contain(result);
    }
Ejemplo n.º 3
0
    public void GetIngredient()
    {
        using var inMemoryDbContext = new InMemoryDbContext();
        var vegetables = new ArticleGroup("Vegetables");
        var tomato     = new Article {
            Name = "Tomato", ArticleGroup = vegetables, IsInventory = false
        };
        var piece = new Unit("Piece");

        inMemoryDbContext.ArticleGroups.Add(vegetables);
        inMemoryDbContext.Articles.Add(tomato);
        inMemoryDbContext.Units.Add(piece);
        var ingredient = inMemoryDbContext.Ingredients.Add(new Ingredient(tomato, 2, piece));

        inMemoryDbContext.SaveChanges();
        var testee = new IngredientDbAccess(inMemoryDbContext);

        var result = testee.GetIngredient(ingredient.Entity.IngredientId);

        result.Article.Name.Should().Be("Tomato");
    }
Ejemplo n.º 4
0
    /// <inheritdoc />
    public IEnumerable <ExistingIngredientDto> GetAllIngredients()
    {
        var ingredients = IngredientDbAccess.GetIngredients();

        return(Mapper.Map <IEnumerable <ExistingIngredientDto> >(ingredients));
    }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public void DeleteIngredient(DeleteIngredientDto deleteIngredientDto)
 {
     IngredientDbAccess.DeleteIngredient(IngredientDbAccess.GetIngredient(deleteIngredientDto.IngredientId));
 }