Beispiel #1
0
        public async Task CreateTag(Tag tag)
        {
            var tagExists = await _recipeDb.Tags
                            .AnyAsync(t => t.Value.Equals(tag.Value, StringComparison.OrdinalIgnoreCase));

            if (tagExists)
            {
                throw new ArgumentException("Tag already exists.");
            }

            _recipeDb.Attach <Tag>(tag);
            await _recipeDb.SaveChangesAsync();
        }
        public async Task CreateRecipe(Recipe recipe)
        {
            _recipeDb.Attach <Recipe>(recipe);

            await _recipeDb.SaveChangesAsync();
        }