Example #1
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("ID,SubCategoryID,Name,Creator,ReleaseDate")] Listing listing, string subcatID)
        {
            if (ModelState.IsValid)
            {
                _context.Add(listing);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Home"));
            }
            ViewData["SubCategoryID"] = new SelectList(_context.SubCategories, "ID", "Name", listing.SubCategoryID);
            return(View(listing));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("ID,CategoryID,Name")] SubCategory subCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "ID", "Name", subCategory.CategoryID);
            return(View(subCategory));
        }