Beispiel #1
0
        public ActionResult PostMessage(PostDTO post)
        {
            if (!ModelState.IsValid)
            {
                return(Json(null));
            }

            PostDTO addedPost;

            try
            {
                addedPost = PostService.Add(post.CourseId, post.Message);

                if (addedPost != null && Request.Files.Count > 0)
                {
                    FileService.Attach(addedPost.Id, addedPost.CourseId, Request.Files);
                    addedPost = PostService.Get(addedPost.Id);
                }
            }
            catch (AccessViolationException)
            {
                return(RedirectToAction("Error", "Account", new { ErrorCase.UnauthorizedAccess }));
            }

            return(Json(addedPost));
        }