コード例 #1
0
        public async Task <IActionResult> Edit(string id, [Bind("Name,CookingInstructions,GlutenFree,Vegetarian,Vegan")] Recipe recipe)
        {
            if (id != recipe.Name)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(recipe);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RecipeExists(recipe.Name))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(recipe));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(string id, [Bind("name,type,expDate,vendor,amount,cost")] Ingredient ingredient)
        {
            if (id != ingredient.name)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ingredient);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IngredientExists(ingredient.name))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ingredient));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(string id, [Bind("username,email")] Login login)
        {
            if (id != login.email)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(login);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LoginExists(login.email))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(login));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(string id, [Bind("Name,Quantity,QuantityReserved,Description,Location")] Equipment equipment)
        {
            if (id != equipment.Name)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(equipment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EquipmentExists(equipment.Name))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(equipment));
        }