Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DishId,IngredientId")] DishIngredient dishIngredient)
        {
            if (id != dishIngredient.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dishIngredient);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DishIngredientExists(dishIngredient.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "DishIngredients", new { id = dishIngredient.DishId, name = _context.Dish.Where(c => c.Id == dishIngredient.DishId).FirstOrDefault().Name }));
            }
            ViewData["DishId"]       = new SelectList(_context.Dish, "Id", "Name", dishIngredient.DishId);
            ViewData["IngredientId"] = new SelectList(_context.Ingredient, "Id", "Name", dishIngredient.IngredientId);
            return(View(dishIngredient));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info")] Type @type)
        {
            if (id != @type.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@type);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeExists(@type.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@type));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,RestaurantId,Address,OpeningTime,ClosingTime")] RestaurantLocation restaurantLocation)
        {
            if (id != restaurantLocation.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(restaurantLocation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RestaurantLocationExists(restaurantLocation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "RestaurantLocations", new { id = restaurantLocation.RestaurantId, name = _context.Restaurant.Where(c => c.Id == restaurantLocation.RestaurantId).FirstOrDefault().Name }));
            }
            ViewData["RestaurantId"] = new SelectList(_context.Restaurant, "Id", "Name", restaurantLocation.RestaurantId);
            return(View(restaurantLocation));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Post,Address")] Client client)
        {
            if (id != client.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,RestaurantId,Name,TypeId,Recipe,Calories,Cost")] Dish dish)
        {
            if (id != dish.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dish);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DishExists(dish.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Dishes", new { id = dish.TypeId, name = _context.Type.Where(c => c.Id == dish.TypeId).FirstOrDefault().Name }));
            }
            ViewData["RestaurantId"] = new SelectList(_context.Restaurant, "Id", "Name", dish.RestaurantId);
            ViewData["TypeId"]       = new SelectList(_context.Type, "Id", "Name", dish.TypeId);
            return(View(dish));
        }