public IActionResult Upsert(BulkyBook.Models.Category category)
 {
     if (ModelState.IsValid)
     {
         if (category.Id == 0)
         {
             _categoryRepository.Add(category);
         }
         else
         {
             _categoryRepository.Update(category);
         }
         _categoryRepository.Commit();
         return(RedirectToAction(nameof(Index))); // action name
     }
     return(View(category));
 }
 public IActionResult Upsert(int?id)
 {
     BulkyBook.Models.Category category = new BulkyBook.Models.Category(); //SOME ERROR with Single class initialization.
     if (id == null)
     {
         // Create
         return(View(category));
     }
     // Update
     category = _categoryRepository.GetById(id.GetValueOrDefault());
     if (category == null)
     {
         // Incorrect ID
         return(NotFound());
     }
     return(View(category));
 }