public async Task <IActionResult> DeleteCategory(int?categoryId) { var category = await _context.TblCategory.SingleOrDefaultAsync(m => m.CategoryId == categoryId); _context.TblCategory.Remove(category); await _context.SaveChangesAsync(); return(RedirectToAction("Category")); /* if (ModelState.IsValid) * { * TblCategory tbl = _context.TblCategory.Where(i => i.CategoryId == categoryId) as TblCategory; * _context.TblCategory.Remove(tbl); * _context.SaveChanges(); * }*/ // return RedirectToAction("Category"); }