Example #1
0
 public ActionResult <CategoryDTO> Post([FromBody] CategoryDTO category)
 {
     try
     {
         return(Ok(_categoryApplicationService.Add(category)));
     }
     catch (Exception ex)
     {
         return(BadRequest(new { message = ex.GetExceptionMessage() }));
     }
 }
Example #2
0
        public IActionResult Create(CategoryViewModel categoryViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(categoryViewModel));
            }

            _applicationService.Add(categoryViewModel);
            TempData["ServerResult"] = IsValidOperation() ? "success;Category created successfully!" : "error;Category was not created. See the notifications for details.";

            return(View(categoryViewModel));
        }