Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Variety variety)
        {
            if (ModelState.IsValid)
            {
                _context.Add(variety);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(variety));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,RecipeCategory")] Recipe recipe)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipe);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(recipe));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Unit,Quantity")] Amount amount)
        {
            if (ModelState.IsValid)
            {
                _context.Add(amount);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(amount));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id")] RecipeIngredient recipeIngredient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipeIngredient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(recipeIngredient));
        }
Exemplo n.º 5
0
        public async Task <RecipeTag> CreateRecipeTag(int recipeId, int tagId)
        {
            var recipeTag = new RecipeTag()
            {
                TagId    = tagId,
                RecipeId = recipeId
            };

            _recipeDb.Add(recipeTag);
            await _recipeDb.SaveChangesAsync();

            return(recipeTag);
        }