Beispiel #1
0
        public async Task <bool> AddCategory(CategoryViewmodel newCategory)
        {
            var entity = new Category
            {
                Id = new Guid(),
                ProductCategory = newCategory.ProductCategory
            };

            _dbContex.Categories.Add(entity);
            return(1 == await _dbContex.SaveChangesAsync());
        }
        public async Task <IActionResult> Post([FromBody] CategoryViewmodel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (await _adminService.AddCategory(model))
            {
                return(new OkObjectResult(new { Message = "Success" }));
            }

            return(BadRequest(Errors.AddErrorToModelState("Message", "Somethins Went Wrong", ModelState)));
        }