public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] FileList fileList)
        {
            if (id != fileList.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fileList);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FileListExists(fileList.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction("Index"));
            }

            return(View(fileList));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] FileList fileList)
        {
            if (id != fileList.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fileList);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FileListExists(fileList.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction("Index"));
            }

            var viewData = new ViewDataDictionary <FileList>(ViewData, fileList);

            return(new ViewResult
            {
                TempData = TempData,
                ViewData = viewData,
                ViewEngine = _viewEngine,
            });
        }