Exemplo n.º 1
0
        public ActionResult AddArticleCategory(ArticleCategory category)
        {
            if (ModelState.IsValid)
            {
                IList<ArticleCategory> cat = new ArticleCategoryDao().GetAll();

                foreach (ArticleCategory c in cat)
                {
                    if (c.Name == category.Name)
                    {
                        TempData["message-unsuccess"] = "Kategorie už existuje";
                        return View("CreateCategory", category);
                    }

                }
                        new ArticleCategoryDao().Create(category);
                        TempData["message-success"] = "Nová kategorie byla přidána";
            }
            else
            {
                return View("CreateCategory", category);
            }

            return RedirectToAction("Kategorie");
        }
Exemplo n.º 2
0
        public ActionResult UpdateCategory(ArticleCategory category)
        {
            try
            {
                new ArticleCategoryDao().Update(category);

                TempData["message-success"] = "Kategorie byla upravena.";
            }
            catch (Exception)
            {

                throw;
            }

            return RedirectToAction("Kategorie");
        }