Ejemplo n.º 1
0
        public IActionResult Edit(int id, [Bind("Id,Name,Address,Description,Rate,ImageUrl,PhoneNumber,WorkingHours,DeliveryAreas,MenuId")] Restaurant restaurant)
        {
            if (id != restaurant.Id)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    _restRepo.UpdateRestaurant(restaurant);
                    _restRepo.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_restRepo.RestaurantExists(restaurant.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MenuId"] = new SelectList(_menuRepo.AllMenus, "Id", "Id");

            return(View(restaurant));
        }