Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,CategoryID,Name")] SubCategory subCategory)
        {
            if (id != subCategory.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubCategoryExists(subCategory.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "ID", "ID", subCategory.CategoryID);
            return(View(subCategory));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,SubCategoryID,Name,Creator,ReleaseDate")] Listing listing, string subcatID)
        {
            if (id != listing.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(listing);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ListingExists(listing.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "Listing", new { id = subcatID }));
            }
            ViewData["SubCategoryID"] = new SelectList(_context.SubCategories, "ID", "Name", listing.SubCategoryID);
            return(View(listing));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Category category)
        {
            if (id != category.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }