public IActionResult Post([FromBody] CategoryViewModel categoryViewModel)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(categoryViewModel));
            }

            _categoryAppService.CreateCategory(categoryViewModel);

            return(Response(categoryViewModel));
        }
        public async Task <IActionResult> Create(CreateCategoryDto input)
        {
            var token    = GetToken();
            var userType = LoginHelper.GetClaim(token, "UserRole");

            if (userType != "Admin")
            {
                return(Unauthorized());
            }

            var result = await _categoryAppService.CreateCategory(input);

            return(Ok(result));
        }
Esempio n. 3
0
        public async Task <IActionResult> CreateCategory(CreateCategoryDto input)
        {
            try
            {
                await _categoryAppService.CreateCategory(input);

                return(Ok("Created category"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }