Ejemplo n.º 1
0
        public async Task <IActionResult> Create(CategoriesCreateInputModel input)
        {
            var newCategory = new Category
            {
                Name = input.Name,
            };

            await this.categoriesRepository.AddAsync(newCategory);

            return(this.Ok());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(CategoriesCreateInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            await this.categoriesService.CreateAsync(input.Name);

            return(this.Redirect("/Home/Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create(CategoriesCreateInputModel input)
        {
            var isExistCategoryName = this.categoriesService.IsExist(input.Name);

            if (isExistCategoryName)
            {
                this.ViewData["Error"] = IsExistCategoryError;
            }

            if (!this.ModelState.IsValid || isExistCategoryName)
            {
                return(this.View());
            }

            await this.categoriesService.CreateAsync(input.Name, input.ImageUrl);

            return(this.Redirect("/Administration/Categories/Manage"));
        }