Exemplo n.º 1
0
        public void Create(CategoryCreateServiceModel model)
        {
            var category = new Category
            {
                Name        = model.Name,
                Description = model.Description
            };

            this.data.Categories.Add(category);
            this.data.SaveChanges();
        }
Exemplo n.º 2
0
        public IActionResult Create(CreateCategoryInputModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.RedirectToAction("Error", "Home"));
            }

            var serviceModel = new CategoryCreateServiceModel
            {
                Name        = model.Name,
                Description = model.Description
            };

            this.categoryService.Create(serviceModel);

            return(this.RedirectToAction("All", "Categories"));
        }