Esempio n. 1
0
 public IActionResult Put(int id, [FromBody] CommentDto dto)
 {
     try
     {
         dto.Id = id;
         editComment.Execute(dto);
         return(StatusCode(204));
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(new
         {
             Errors = new List <string> {
                 e.Message
             }
         }));
     }
     catch (Exception e)
     {
         return(StatusCode(500, new
         {
             Errors = new List <string> {
                 e.Message
             }
         }));
     }
 }
Esempio n. 2
0
 public ActionResult Edit(int id, Comment comment)
 {
     _editCommentCommand.Execute(new EditCommentDto()
     {
         Id      = id,
         Comment = comment.Comments,
         UserId  = GetUserId().Result
     });
     return(RedirectToAction("Index", "Home"));
 }
        public ActionResult Put(int id, [FromBody] EditCommentDto dto)
        {
            dto.Id = id;
            try
            {
                _editComment.Execute(dto);
                return(StatusCode(204));
            }
            catch (EntityNotFoundException e) { return(NotFound(e.Message)); }

            catch (Exception e) { return(StatusCode(500, e.Message)); }
        }
 public ActionResult <IEnumerable <CommentDTO> > Put(int id, [FromBody] CommentDTO dto)
 {
     try
     {
         _editCommentCommand.Execute(dto);
         return(NoContent());
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error has occured !!"));
     }
 }
Esempio n. 5
0
 public IActionResult Put(int id, [FromBody] EditCommentsViewModel viewModel)
 {
     try
     {
         _editCommentCommand.Execute(new EditCommentDto()
         {
             UserId  = GetUserId().Result,
             Comment = viewModel.Comment,
             Id      = id
         });
         return(StatusCode(201, "Uspesno azuriran komentar"));
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
        public ActionResult Put(int id, [FromBody] CommentDto dto)
        {
            dto.Id = id;

            try
            {
                _editCommand.Execute(dto);
                return(NoContent());
            }
            catch (EntityNotFoundException e)
            {
                return(NotFound(e.Message));
            }

            catch (Exception)
            {
                return(StatusCode(500, "Server error has occurred."));
            }
        }
Esempio n. 7
0
        public ActionResult Edit(int id, CreateCommentDto updateDto)
        {
            if (!ModelState.IsValid)
            {
                TempData["greska"] = "Doslo je do greske pri unosu";
                RedirectToAction("Edit");
            }
            try
            {
                updateDto.CommentId = id;
                _editCommentCommand.Execute(updateDto);

                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityNotFoundException ex)
            {
                TempData["error"] = ex.Message;
                return(View());
            }
        }
Esempio n. 8
0
        public ActionResult Edit(int id, CommentDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(dto));
            }

            try
            {
                _editCommand.Execute(dto);
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityNotFoundException)
            {
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception)
            {
                TempData["error"] = "Error";
                return(View(dto));
            }
        }
Esempio n. 9
0
      public IActionResult Put(int id, [FromBody] CreateCommentDto createDto)
      {
          createDto.CommentId = id;
          try
          {
              _editCommentCommand.Execute(createDto);
              return(NoContent());
          }
          catch (EntityNotFoundException e)
          {
              if (e.Message == "Comment doesn't exist.")
              {
                  return(NotFound(e.Message));
              }

              return(UnprocessableEntity(e.Message));
          }
          catch (Exception e)
          {
              return(StatusCode(500));
          }
      }
Esempio n. 10
0
 public ActionResult Put(int id, [FromBody] CommentDTO value)
 {
     try
     {
         editCommentCommand.Execute(value);
         return(NoContent());
     }
     catch (DataNotFoundException)
     {
         return(NotFound());
     }
     catch (DataAlreadyExistsException)
     {
         return(Conflict());
     }
     catch (DataNotAlteredException)
     {
         return(Conflict("Data not altered"));
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }