コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Code,Address")] ROMTestModel rOMTestModel)
        {
            if (id != rOMTestModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rOMTestModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ROMTestModelExists(rOMTestModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(rOMTestModel));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Code,Address")] ROMTestModel rOMTestModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rOMTestModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rOMTestModel));
        }