Ejemplo n.º 1
0
 public ActionResult Edit(int id, CategoryDTO collection)
 {
     if (!ModelState.IsValid)
     {
         return(View(collection));
     }
     try
     {
         editCategoryCommand.Execute(collection);
         return(RedirectToAction("Index"));
     }
     catch (DataNotFoundException)
     {
         return(RedirectToAction("Index"));
     }
     catch (DataAlreadyExistsException)
     {
         TempData["error"] = "Name already exists!";
         return(null);
     }
     catch (DataNotAlteredException)
     {
         TempData["error"] = "Name was not altered!";
         return(null);
     }
     catch (Exception)
     {
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult <IEnumerable <CategoryDTO> > Put(int id, [FromBody] CategoryDTO dto)
 {
     try
     {
         _editCommand.Execute(dto);
         return(NoContent());
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error has occured !!"));
     }
 }
Ejemplo n.º 3
0
 public ActionResult Put(int id, [FromBody] CategoryPostDto dto)
 {
     try
     {
         _editCategory.Execute(dto);
         return(NoContent());
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error has occured."));
     }
 }
Ejemplo n.º 4
0
 public IActionResult Put(int id, [FromBody] NapraviNovuKategoriju kategorija)
 {
     try
     {
         kategorija.KategorijaId = id;
         _editCategoryCommand.Execute(kategorija);
         return(Ok());
     }
     catch (Exception e)
     {
         return(UnprocessableEntity(e.Message));
     }
 }
Ejemplo n.º 5
0
 public IActionResult Put(int id, [FromBody] CategoryDto dto)
 {
     try
     {
         dto.Id = id;
         _editCategory.Execute(dto);
         return(StatusCode(422));
     }
     catch (NotFoundException)
     {
         return(NotFound());
     }
     catch (EntityAlreadyExistsException)
     {
         return(StatusCode(422));
     }
 }
Ejemplo n.º 6
0
 public ActionResult Edit(int id, CategoryDto dto)
 {
     if (!ModelState.IsValid)
     {
         return(View(dto));
     }
     try
     {
         _editCategory.Execute(dto);
         return(RedirectToAction(nameof(Index)));
     }
     catch (NotFoundException)
     {
         return(RedirectToAction(nameof(Index)));
     }
     catch (EntityAlreadyExistsException)
     {
         TempData["error"] = "Category with the same name already exist.";
         return(View(dto));
     }
 }
 public ActionResult Put(int id, [FromBody] CategoryDto dto)
 {
     dto.Id = id;
     try
     {
         _editCommand.Execute(dto);
         return(NoContent());
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (EntityAlreadyExistsException e)
     {
         return(Conflict(e.Message));
     }
     catch (Exception)
     {
         return(StatusCode(500, "Server error has occurred."));
     }
 }
Ejemplo n.º 8
0
        public IActionResult Put(int id, [FromBody] CreateCategoryDto category)
        {
            category.CategoryId = id;
            try
            {
                _editCategoryCommand.Execute(category);
                return(NoContent());
            }
            catch (EntityNotFoundException e)
            {
                if (e.Message == "Category doesn't exist.")
                {
                    return(NotFound(e.Message));
                }

                return(UnprocessableEntity(e.Message));
            }
            catch (Exception e)
            {
                return(StatusCode(500));
            }
        }
Ejemplo n.º 9
0
        public ActionResult Edit(int id, CategoryPostDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(dto));
            }

            try
            {
                _editCategory.Execute(dto);
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityNoFound)
            {
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityAlreadyExists)
            {
                TempData["error"] = "Kategorija sa istim imenom vec postoji.";
                return(View(dto));
            }
        }
Ejemplo n.º 10
0
        public ActionResult Edit(int id, CategoryDTO category)
        {
            if (!ModelState.IsValid)
            {
                return(View(category));
            }

            try
            {
                _editCategoryCommand.Execute(category);
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityExistException)
            {
                TempData["error"] = "Category already exist!";
            }
            catch (EntityNotFoundException)
            {
                return(RedirectToAction(nameof(Index)));
            }

            return(View());
        }
Ejemplo n.º 11
0
 public ActionResult Put(int id, [FromBody] CategoryDTO value)
 {
     try
     {
         editCategoryCommand.Execute(value);
         return(NoContent());
     }
     catch (DataNotFoundException)
     {
         return(NotFound());
     }
     catch (DataNotAlteredException)
     {
         return(Conflict("Data not altered"));
     }
     catch (DataAlreadyExistsException)
     {
         return(Conflict());
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }