Example #1
0
        public ActionResult AddSubcategory(int categoryId, SubcategorySubmitDTO s)
        {
            if (Session["AdminLoggedIn"] == null)
            {
                return(RedirectToAction("AdminLoggInn"));
            }

            if (ModelState.IsValid)
            {
                if (s.Name == null)
                {
                    TempData["Feil"] = "Underkategorinavn kan ikke være tomt";
                }
                else if (s.Instruction == null)
                {
                    TempData["Feil"] = "Instruksjon kan ikke være tom";
                }
                else
                {
                    try
                    {
                        adminBL.AddSubcategory(categoryId, s);
                        TempData["Melding"] = "Underkategori " + s.Name + " lagt til.";
                    }
                    catch (DataException e) {
                        TempData["Feil"] = "Databasefeil ved innlegging av underkategori.";
                    }
                }
            }
            return(RedirectToAction("SubcategoryEditor", new { id = categoryId }));
        }
Example #2
0
 //Johan
 //add subcategory with instruction
 //ryddet Tetiana
 public void AddSubcategory(int categoryId, SubcategorySubmitDTO s)
 {
     adminDAL.AddSubcategory(categoryId, s.Name, s.Instruction);
 }