public ActionResult PostImageUpload(NewPost model)
        {
            string result;
            var serializer = new JavaScriptSerializer();
            try
            {
                // upload the file
                if (model.File != null && model.File.ContentLength > 0)
                {
                    Guid id = new Guid();
                    if (model.ForumType == ForumOwnerTypeEnum.league)
                        id = Forum.GetLeagueIdOfForum(model.ForumId);
                    else if (model.ForumType == ForumOwnerTypeEnum.federation)
                        id = Forum.GetFederatonIdOfForum(model.ForumId);
                    if (id != new Guid())
                    {
                        var doc = DocumentRepository.UploadLeagueDocument(id, model.File.InputStream, model.File.FileName, "Forum Files");
                        FileInfo fi = new FileInfo(doc.SaveLocation);

                        result = serializer.Serialize(
                            new { success = true, imagePath = RDN.Portable.Config.ServerConfig.WEBSITE_INTERNAL_DEFAULT_LOCATION + "/document/view/" + doc.DocumentId.ToString().Replace("-", "") + fi.Extension });
                        return Content(result); // IMPORTANT to return as HTML
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            result = serializer.Serialize(
                        new { success = false, message = "Invalid image file" });
            return Content(result);
        }
        public ActionResult QuotePost(NewPost newPost)
        {
            try
            {
                Guid memId = RDN.Library.Classes.Account.User.GetMemberId();

                if (!MemberCache.IsMemberApartOfForum(memId, newPost.ForumId) && !MemberCache.IsAdministrator(memId))
                    return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.na));

                var topic = Forum.GetForumMessage(newPost.ForumId, newPost.MessageId);


                if (newPost.Message.Contains("[quote]") && newPost.Message.Contains("[/quote]"))
                {
                    string headQuote = "<div class='quoteForumMessage'><div class='topslice_quote'>";
                    headQuote += "<span>Quote from: " + topic.Member.DerbyName + " on " + topic.Created.ToString() + "</span>";
                    headQuote += "</div><blockquote class='bbc_standard_quote'>";
                    newPost.Message = newPost.Message.Replace("[quote]", headQuote);
                    string footQuote = "</blockquote><div class='quotefooter'><div class='botslice_quote'></div></div></div>";
                    newPost.Message = newPost.Message.Replace("[/quote]", footQuote);
                }

                Forum.ReplyToPost(newPost.ForumId, newPost.TopicId, newPost.Message, memId, newPost.BroadcastMessage);
                ForumTopicCache.ClearTopicCache(newPost.ForumId, newPost.TopicId);
                WebClient client = new WebClient();
                client.DownloadStringAsync(new Uri(ServerConfig.URL_TO_CLEAR_FORUM_TOPIC_API + "forumId=" + newPost.ForumId + "&topicId=" + newPost.TopicId));
                return Redirect(Url.Content("~/forum/post/view/" + newPost.ForumId.ToString().Replace("-", "") + "/" + newPost.TopicId));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }