コード例 #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("BlockedRestaurantId,RestaurantId,UserId")] BlockedRestaurant blockedRestaurant)
        {
            if (id != blockedRestaurant.BlockedRestaurantId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blockedRestaurant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlockedRestaurantExists(blockedRestaurant.BlockedRestaurantId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RestaurantId"] = new SelectList(_context.Restaurants, "RestaurantId", "RestaurantId", blockedRestaurant.RestaurantId);
            ViewData["UserId"]       = new SelectList(_context.Users, "UserId", "Email", blockedRestaurant.UserId);
            return(View(blockedRestaurant));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("BlockedRestaurantId,RestaurantId,UserId")] BlockedRestaurant blockedRestaurant)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blockedRestaurant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RestaurantId"] = new SelectList(_context.Restaurants, "RestaurantId", "RestaurantId", blockedRestaurant.RestaurantId);
            ViewData["UserId"]       = new SelectList(_context.Users, "UserId", "Email", blockedRestaurant.UserId);
            return(View(blockedRestaurant));
        }