public async Task <IActionResult> Edit(int id, [Bind("FurnitureCategoryID,FurnitureCategoryName")] FurnitureCategory furnitureCategory)
        {
            if (id != furnitureCategory.FurnitureCategoryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(furnitureCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FurnitureCategoryExists(furnitureCategory.FurnitureCategoryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(furnitureCategory));
        }
        public async Task <IActionResult> Create([Bind("FurnitureCategoryID,FurnitureCategoryName")] FurnitureCategory furnitureCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(furnitureCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(furnitureCategory));
        }
Example #3
0
        // In real App it should be downloaded by REST Request or direct DB connection (not recommended in my opinion)
        public Task <IEnumerable <FurnitureItem> > GetFurnitureItems(FurnitureCategory category)
        {
            var categoryItems = _furnitureItems.Where(x => x.Value.Category == category).Select(x => x.Value);

            return(Task.FromResult(categoryItems));
        }
Example #4
0
 public ChairInteractableObject()
 {
     Category    = new FurnitureCategory();
     SubCategory = new ChairSubCategory();
     SetCardableObject();
 }
 public void Category(FurnitureCategory category)
 {
     throw new NotImplementedException();
 }