コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,Ip,ReloadDate")] Server server)
        {
            if (id != server.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(server);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServerExists(server.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(server));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ServerId,Text,ProcessingDate,Type,Priority,LoadLevel")] Message message)
        {
            if (id != message.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(message);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MessageExists(message.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.Types        = new SelectList(func.TypeList.AsEnumerable());
            ViewData["ServerId"] = new SelectList(_context.Set <Server>(), "Id", "Id", message.ServerId);
            return(View(message));
        }