Esempio n. 1
0
        public IActionResult Create(Catagory newCatagory)
        {
            if (ModelState.IsValid)
            {
                Catagory catagory = new Catagory();
                catagory.Id   = newCatagory.Id;
                catagory.Name = newCatagory.Name;

                bool isSaved = _catagoryManager.Add(catagory);

                if (isSaved)
                {
                    return(RedirectToAction("List", "Category", null));
                }
            }
            return(View());
        }
 public ActionResult Create(CatagoryViewModel catagoryViewModel)
 {
     if (ModelState.IsValid)
     {
         Catagory catagory = new Catagory()
         {
             Name       = catagoryViewModel.Name,
             CategoryId = catagoryViewModel.CatagoryId
         };
         bool isAdded = _manager.Add(catagory);
         if (isAdded)
         {
             TempData["msg"] = "Category Inserted Successfully!";
             return(RedirectToAction("Create"));
         }
     }
     return(View(catagoryViewModel));
 }