public ActionResult Create(SubCategories subCategories, string PostMethod)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             var viewModel = new CatSubCatViewModel
             {
                 subCategories = subCategories,
                 categories    = _context.categories.ToList()
             };
         }
         subCategories.ApplicationUserCreatedById     = "4af95f1c-0f73-4df9-bb6d-166a07b6e5f4";
         subCategories.ApplicationUserCreatedDate     = DateTime.Now;
         subCategories.ApplicationUserLastUpdatedById = subCategories.ApplicationUserCreatedById;
         subCategories.ApplicationUserLastUpdatedDate = DateTime.Now;
         // TODO: Add insert logic here
         _context.subCategories.Add(subCategories);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Edit(int id, SubCategories subCategories)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var viewModel = new CatSubCatViewModel
                    {
                        subCategories = subCategories,
                        categories    = _context.categories.ToList()
                    };

                    //return View("CustomerForm", viewModel);
                }
                // TODO: Add update logic here
                var subcatinDb = _context.subCategories.Single(s => s.Id == subCategories.Id);
                subcatinDb.CategoryID    = subCategories.CategoryID;
                subcatinDb.SubCatDesc    = subCategories.SubCatDesc;
                subcatinDb.TimeInMinutes = subCategories.TimeInMinutes;

                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Index"));
            }
        }
 // GET: SubCategories/Create
 public ActionResult Create(SubCategories subCategories)
 {
     if (!ModelState.IsValid)
     {
         var viewModel = new CatSubCatViewModel
         {
             subCategories = subCategories,
             categories    = _context.categories.ToList()
         };
         return(View("Create", viewModel));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        // GET: SubCategories/Edit/5
        public ActionResult Edit(int id)
        {
            var subCat = _context.subCategories.SingleOrDefault(c => c.Id == id);

            if (subCat == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new CatSubCatViewModel
            {
                subCategories = subCat,
                categories    = _context.categories.ToList()
            };

            return(View(viewModel));
        }