コード例 #1
0
        public IActionResult EditCategoryTest(EditCategoryTestViewModel viewModel)
        {
            var originalCategoryID = viewModel.Test.CategoryID;

            viewModel.Test.CategoryID = viewModel.SelectedCategoryID;

            _database.CategoryTests.Update(viewModel.Test);
            _database.SaveChanges();

            return(RedirectToAction("CategoryDetails", new { id = originalCategoryID }));
        }
コード例 #2
0
        public IActionResult EditCategoryTest(Guid id)
        {
            var test       = _database.CategoryTests.Find(id);
            var categories = _database.Categories.ToList();

            if (test == null)
            {
                return(NotFound());
            }

            var viewModel = new EditCategoryTestViewModel
            {
                SelectedCategoryID = test.CategoryID,
                CategoriesList     = new SelectList(categories, "ID", "Name"),
                Test = test,
            };

            return(View(viewModel));
        }