Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("CatId,CatName")] Categories categories)
        {
            if (id != categories.CatId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categories);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoriesExists(categories.CatId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categories));
        }
        public async Task <IActionResult> Edit(int id, [Bind("SubId,SubName,CatId")] Subcategories subcategories)
        {
            if (id != subcategories.SubId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subcategories);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubcategoriesExists(subcategories.SubId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CatId"] = new SelectList(_context.Categories, "CatId", "CatName", subcategories.CatId);
            return(View(subcategories));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Question,Answer,QaId,SubId")] QaDetails qaDetails)
        {
            if (id != qaDetails.QaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(qaDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QaDetailsExists(qaDetails.QaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubId"] = new SelectList(_context.Subcategories, "SubId", "SubName", qaDetails.SubId);
            return(View(qaDetails));
        }