Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("FurnitureSubCategoryID,FurnitureSubCategoryName,FurnitureCategoryID")] FurnitureSubCategory furnitureSubCategory)
        {
            if (id != furnitureSubCategory.FurnitureSubCategoryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(furnitureSubCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FurnitureSubCategoryExists(furnitureSubCategory.FurnitureSubCategoryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FurnitureCategoryID"] = new SelectList(_context.FurnitureCategories, "FurnitureCategoryID", "FurnitureCategoryName", furnitureSubCategory.FurnitureCategoryID);
            return(View(furnitureSubCategory));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("FurnitureSubCategoryID,FurnitureSubCategoryName,FurnitureCategoryID")] FurnitureSubCategory furnitureSubCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(furnitureSubCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FurnitureCategoryID"] = new SelectList(_context.FurnitureCategories, "FurnitureCategoryID", "FurnitureCategoryName", furnitureSubCategory.FurnitureCategoryID);
            return(View(furnitureSubCategory));
        }