public ActionResult Input(string id = "")
 {
     if (string.IsNullOrEmpty(id))
     {
         ViewBag.Title = "Add new Category";
         Category newCategory = new Category();
         newCategory.CategoryID = 0;
         return(View(newCategory));
     }
     else
     {
         try
         {
             ViewBag.Title = "Edit Category";
             Category editCategory = CatalogBLL.Category_Get(Convert.ToInt32(id));
             if (editCategory == null)
             {
                 return(RedirectToAction("Index"));
             }
             return(View(editCategory));
         }
         catch (FormatException)
         {
             return(RedirectToAction("Index"));
         }
     }
 }
        public ActionResult Input(string id = "")
        {
            if (string.IsNullOrEmpty(id))
            {
                ViewBag.Title         = "Add New Category";
                ViewBag.ConfirmButton = "Add";

                Category newCategory = new Category();
                newCategory.CategoryID = 0;
                return(View(newCategory));
            }
            else
            {
                ViewBag.Title         = "Edit Category";
                ViewBag.ConfirmButton = "Save";
                try
                {
                    Category editCategory = CatalogBLL.Category_Get(Convert.ToInt32(id));
                    if (editCategory == null)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(View(editCategory));
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return(RedirectToAction("Index"));
                }
            }
        }
Beispiel #3
0
 public ActionResult Detail(string id = "")
 {
     if (string.IsNullOrEmpty(id))
     {
         return(RedirectToAction("Index"));
     }
     try
     {
         Category model = CatalogBLL.Category_Get(Convert.ToInt32(id));
         return(View(model));
     }
     catch (Exception e)
     {
         return(RedirectToAction("Index"));
     }
 }