Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,Name")] CategoryDTO categoryDto)
        {
            if (ModelState.IsValid)
            {
                _categoryLogic.Add(categoryDto);

                return(RedirectToAction("Index"));
            }

            return(View(categoryDto));
        }
Exemplo n.º 2
0
        public IActionResult Create(CategoryViewModel model)
        {
            var category = new Category
            {
                Id       = 0,
                Name     = model.Name,
                ParentId = model.SelectedParent
            };

            if (ModelState.IsValid)
            {
                _categoryLogic.Add(category);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }