Esempio n. 1
0
        public IActionResult AddComment(string commentContent, int newsId)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(commentContent))
                {
                    SetError("Komentarz nie może być pusty.");
                }
                else if (commentContent.Length > 150)
                {
                    SetError("Długość komentarza nie może przekraczać 150 znaków.");
                }
                else
                {
                    _newsService.AddComment(commentContent, newsId, GetUserId());
                    SetSuccess("Pomyślnie dodano komentarz!");
                }
            }
            catch (Exception e)
            {
                SetError(e);
            }

            return(RedirectToAction("Details", new { id = newsId }));
        }