Ejemplo n.º 1
0
 public IActionResult Post([FromBody] CategoryDto dto)
 {
     try
     {
         _addCategory.Execute(dto);
         return(StatusCode(200));
     }
     catch (EntityAlreadyExistsException)
     {
         return(NotFound());
     }
 }
Ejemplo n.º 2
0
 public IActionResult Post([FromBody] CategoryDto dto)
 {
     try
     {
         _addCategory.Execute(dto);
         return(StatusCode(201));
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }
Ejemplo n.º 3
0
 public IActionResult Post([FromBody] CreateCategoryDto categoryDto)
 {
     try
     {
         _addCategoryCommand.Execute(categoryDto);
         return(StatusCode(201));
     }
     catch
     {
         return(StatusCode(500, "An error has occured."));
     }
 }
Ejemplo n.º 4
0
 public IActionResult Post([FromBody] NapraviNovuKategoriju kategorija)
 {
     try
     {
         _addCategoryCommand.Execute(kategorija);
         return(Ok());
     }
     catch (EntityAlreadyExists e)
     {
         return(UnprocessableEntity(e.Message));
     }
 }
Ejemplo n.º 5
0
 public ActionResult Post([FromBody] CategoryDTO value)
 {
     try
     {
         addCategoryCommand.Execute(value);
         return(StatusCode(201));
     }
     catch (DataAlreadyExistsException)
     {
         return(Conflict());
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }
 public IActionResult Post([FromBody] CategoryDto dto)
 {
     try
     {
         _addCommand.Execute(dto);
         return(NoContent());
     }
     catch (EntityAlreadyExistsException)
     {
         return(Conflict("Postoji vec sa takvim imenom"));
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error has occured"));
     }
 }
Ejemplo n.º 7
0
 public ActionResult Post([FromBody] CategoryPostDto dto)
 {
     try
     {
         _addCategory.Execute(dto);
         return(StatusCode(201));
     }
     catch (EntityAlreadyExists)
     {
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error has occured."));
     }
 }
 public ActionResult Post([FromBody] CategoryDto dto)
 {
     try
     {
         _addCommand.Execute(dto);
         return(StatusCode(201));
     }
     catch (EntityAlreadyExistsException e)
     {
         return(Conflict(e.Message));
     }
     catch (Exception)
     {
         return(StatusCode(500, "Server error has occurred."));
     }
 }
        public ActionResult <IEnumerable <CategoryDTO> > Post([FromBody] CategoryDTO dto)
        {
            try
            {
                _addCommand.Execute(dto);

                return(Created("/api/categories/" + dto.Id, new CategoryDTO
                {
                    Id = dto.Id,
                    Name = dto.Name
                }));
            }
            catch
            {
                return(StatusCode(500, "An error has occured !!"));
            }
        }
Ejemplo n.º 10
0
 public IActionResult Post([FromQuery] CreateCategoryDto dto)
 {
     try
     {
         _addCommand.Execute(dto);
         return(Created("Api/Categories", new CategoryDto {
             Name = dto.Name
         }));
     }
     catch (EntityAlreadyExistsException)
     {
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error has occured."));
     }
 }
Ejemplo n.º 11
0
        public ActionResult Create(CategoryPostDto dto)
        {
            try
            {
                _addCategory.Execute(dto);

                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityNoFound n)
            {
                return(NotFound());
            }
            catch (Exception e)
            {
                TempData["greska"] = "Doslo je do greske.";
            }
            return(View());
        }
Ejemplo n.º 12
0
        public ActionResult Create(CreateCategoryDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(dto));
            }

            try
            {
                _addCommand.Execute(dto);
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityAlreadyExistsException) {
                TempData["error"] = "Category with the same name already exists";
            }
            catch (Exception)
            {
                TempData["error"] = "An error occured";
            }
            return(View());
        }
Ejemplo n.º 13
0
 public ActionResult Create(CategoryDTO collection)
 {
     if (!ModelState.IsValid)
     {
         TempData["error"] = "Category name error";
         RedirectToAction("create");
     }
     try
     {
         addCategoryCommand.Execute(collection);
     }
     catch (DataAlreadyExistsException)
     {
         TempData["error"] = "Already same name exists!";
     }
     catch (Exception)
     {
         TempData["error"] = "Something is wrong!";
     }
     return(View());
 }
Ejemplo n.º 14
0
        public ActionResult Create(CategoryDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(dto));
            }
            try
            {
                // TODO: Add insert logic here
                _addCategory.Execute(dto);
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityAlreadyExistsException)
            {
                TempData["error"] = "Category with the same name already exists.";
            }
            catch (Exception)
            {
                TempData["error"] = "Some error occurred. Please try again.";
            }

            return(View());
        }
Ejemplo n.º 15
0
        public ActionResult Create(CategoryDTO collection)
        {
            if (!ModelState.IsValid)
            {
                return(View(collection));
            }

            try
            {
                _addCommand.Execute(collection);
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityNotFoundException)
            {
                TempData["error"] = "Post with same name already exist!";
            }
            catch (Exception)
            {
                TempData["error"] = "An error has occured!";
            }

            return(View());
        }