Example #1
0
        public ActionResult Create([Bind(Include = "CategoryID,CategoryName")] Category category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (Repos repo = new Repos())
                    {
                        repo.AddCategory(category);
                    }
                    return RedirectToAction("Index");
                }
                return View(category);
            }
            catch (Exception) { }

            //TODO - error when adding new category
            //return RedirectToAction("Create", new { error = "You cannot add duplicate answers" });
            return RedirectToAction("Create");
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "CategoryID,CategoryName")] Category category)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (Repos repo = new Repos())
             {
                 repo.AddCategory(category);
             }
             return View(category);
         }
     }
     catch (Exception) { }
     return RedirectToAction("Index");
 }