public ActionResult Create(ForumMessage msg)
 {
     if (Session["LoggedUserName"] == null)
     {
         Logging.Log("POST : Forum create message page", Logging.AccessType.Anonymous);
         return(RedirectToAction("Index", "Login"));
     }
     if (ModelState.IsValid)
     {
         var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLiteConnection"].ConnectionString;
         using (var m_dbConnection = new SQLiteConnection(connectionString))
         {
             m_dbConnection.Open();
             SQLiteCommand command = new SQLiteCommand("INSERT INTO tblforum (userId, subject, body) VALUES (@userId,@subject,@body)", m_dbConnection);
             command.Parameters.AddWithValue("@userId", int.Parse(Session["LoggedUserId"].ToString()));
             command.Parameters.AddWithValue("@body", AntiXssEncoder.HtmlEncode(msg.Body, true));
             command.Parameters.AddWithValue("@subject", AntiXssEncoder.HtmlEncode(msg.Subject, true));
             try
             {
                 command.ExecuteNonQuery();
                 Logging.Log("POST : Successful creation of a forum post", Logging.AccessType.Valid);
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
     return(RedirectToAction("Index"));
 }
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            ForumMessage forumMessage = new ForumMessage();
            forumMessage.userId       = userId;
            forumMessage.forumTopicId = forumTopicId;
            forumMessage.userName     = tbName.Text.Trim();
            forumMessage.text         = tbText.Text.Trim();

            using (GmConnection conn = Global.CreateConnection())
            {
                forumMessage.Save(conn);
            }
            Server.Transfer("ForumMessages.aspx?ft=" + forumTopicId);
            //			lblResult.Text = string.Format("Message добавлено.");
            //			WebUtils.Redirect(this, "Private/Users.aspx");
        }
        catch (System.Threading.ThreadAbortException ex)
        {
        }
        catch (Exception ex)
        {
            log.Exception(ex);
        }
    }
Example #3
0
        private async Task <List <Forum> > SignAsync(IEnumerable <Forum> list, ForumMessage message, CancellationToken token)
        {
            var failList = new List <Forum>();

            foreach (var forum in list)
            {
                token.ThrowIfCancellationRequested();
                try
                {
                    var res = await Manager.SignAsync(forum, message, token);

                    Logger.LogInformation($@"{Timestamp.GetTime(res.sign_time).ToLocalTime()} {forum.name}:{res.level_name}:今日本吧第 {res.user_sign_rank} 个签到,经验 +{res.sign_bonus_point},漏签 {res.miss_sign_num} 天,连续签到 {res.cont_sign_num} 天");
                }
                catch (TiebaErrorException ex) when(ex.Error.error_code == @"160002")
                {
                    Logger.LogInformation(@"{0} 已签到", forum.name);
                }
                catch (TiebaErrorException ex) when(ex.Error.error_code == @"340008")
                {
                    Logger.LogInformation(@"{0} 在黑名单中,不能操作", forum.name);
                }
                catch (Exception ex) when(ex is not TaskCanceledException)
                {
                    failList.Add(forum);
                    Logger.LogError(ex, @"{0} 签到失败", forum.name);
                }
            }

            return(failList);
        }
        public async Task <IActionResult> Create(ForumMessagesCreateModel model, Guid?forumTopicId)
        {
            var user = await this.userManager.GetUserAsync(this.HttpContext.User);

            if (forumTopicId == null)
            {
                return(NotFound());
            }

            var forumTopic = await _context.ForumTopics
                             .SingleOrDefaultAsync(x => x.Id == forumTopicId);

            if (forumTopic == null || user == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                DateTime now          = DateTime.UtcNow;
                var      forumMessage = new ForumMessage
                {
                    Text         = model.Text,
                    Created      = now,
                    CreatorId    = user.Id,
                    ForumTopicID = (Guid)forumTopicId
                };
                this._context.Add(forumMessage);
                await this._context.SaveChangesAsync();

                return(this.RedirectToAction("Details", "ForumTopics", new { id = forumTopic.Id }));
            }
            ViewBag.ForumTopic = forumTopic;
            return(View(model));
        }
Example #5
0
 public ActionResult Create(NewTopicModel topic)
 {
     using (NHibernate.ISession session = nHibernateHelper.OpenSession())
     {
         using (ITransaction transaction = session.BeginTransaction())
         {
             var aTopic = new Topic
             {
                 Category = session.Query <Category>().Single(x => x.Id == topic.CategoryId),
                 Name     = topic.Name,
                 Date     = DateTime.Now,
                 User     = session.Query <User>().Single(x => x.Email == User.Identity.Name),
                 IsClosed = false,
             };
             var initMsg = new ForumMessage
             {
                 Text  = topic.InitialText,
                 User  = aTopic.User,
                 Date  = aTopic.Date,
                 Topic = aTopic,
             };
             aTopic.Messages.Add(initMsg);
             session.SaveOrUpdate(aTopic);
             session.SaveOrUpdate(initMsg);
             transaction.Commit();
             var dbTopic = session.Query <Topic>().Single(x => x.Name == aTopic.Name && x.Date == aTopic.Date);
             return(CreatedAtRoute("GetTopic", new { id = dbTopic.Id }, new TopicAPIModel(dbTopic)));
         }
     }
 }
Example #6
0
 public async Task Send(string message, int topicId)
 {
     using (ISession session = nHibernateHelper.OpenSession())
     {
         var topic = session.Query <Topic>().Single(x => x.Id == topicId);
         if (!topic.IsClosed)
         {
             var msg = new ForumMessage
             {
                 User  = session.Query <User>().Single(x => x.Email == Context.User.Identity.Name),
                 Date  = DateTime.Now,
                 Text  = message,
                 Topic = topic,
             };
             using (ITransaction transaction = session.BeginTransaction())
             {
                 topic.Messages.Add(msg);
                 session.SaveOrUpdate(msg);
                 session.SaveOrUpdate(topic);
                 transaction.Commit();
             }
             var dbMsg = session.Query <ForumMessage>().Single(x => x.Date == msg.Date);
             await Clients.All.SendAsync($"Receive{topicId.ToString()}", new MessageAPIModel(dbMsg));
         }
     }
 }
        // Controller for Forum Page

        // Retreive the main forum page
        public ActionResult Index()
        {
            if (Session["LoggedUserName"] == null)
            {
                Logging.Log("Forum page", Logging.AccessType.Anonymous);
                return(RedirectToAction("Index", "Login"));
            }
            List <ForumMessage> msgs = new List <ForumMessage>();
            ForumMessage        msg;
            var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLiteConnection"].ConnectionString;

            using (var m_dbConnection = new SQLiteConnection(connectionString))
            {
                m_dbConnection.Open();
                SQLiteCommand command = new SQLiteCommand("SELECT * FROM tblforum", m_dbConnection);
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        // adding messages to the list
                        msg           = new ForumMessage();
                        msg.MessageID = reader.GetInt32(0);
                        msg.UserID    = reader.GetInt32(1);
                        msg.Subject   = reader.GetString(2).Trim();
                        msg.Body      = reader.GetString(3).Trim();
                        msgs.Add(msg);
                    }
                }
            }
            Logging.Log("Successful login to the forum page", Logging.AccessType.Valid);
            return(View(msgs));
        }
        public async Task <IActionResult> Create(Guid?TopicId, ForumMessageCreateModel model)
        {
            if (TopicId == null)
            {
                return(this.NotFound());
            }

            var topic = await this._context.ForumTopics
                        .SingleOrDefaultAsync(x => x.Id == TopicId);

            if (topic == null)
            {
                return(this.NotFound());
            }

            if (this.ModelState.IsValid)
            {
                var message = new ForumMessage
                {
                    Text              = model.Text,
                    Created           = DateTime.Now,
                    Modified          = DateTime.Now,
                    ApplicationUserId = _userManager.GetUserId(User),
                    ForumTopicId      = (Guid)TopicId
                };

                this._context.Add(message);
                await this._context.SaveChangesAsync();

                return(this.RedirectToAction("Index", new { topicId = topic.Id }));
            }

            this.ViewBag.Topic = topic;
            return(this.View(model));
        }
        public async Task <IActionResult> Create(Guid?topicId, ForumMessageViewModel model)
        {
            if (topicId == null)
            {
                return(this.NotFound());
            }

            var user = await this.userManager.GetUserAsync(this.HttpContext.User);

            if (this.ModelState.IsValid && user != null)
            {
                var forumMessage = new ForumMessage
                {
                    Created  = DateTime.UtcNow,
                    Modified = DateTime.UtcNow,
                    Text     = model.Text,
                    TopicId  = (Guid)topicId,
                    UserId   = user.Id
                };

                this.context.ForumMessages.Add(forumMessage);
                await this.context.SaveChangesAsync();

                return(this.RedirectToAction("Index", new { topicId }));
            }

            return(this.View(model));
        }
Example #10
0
        public async Task <IActionResult> Create(Guid id, ForumMessagesEditViewModel model)
        {
            if (id == null)
            {
                return(this.NotFound());
            }
            var topic = await this._context.ForumTopics
                        .SingleOrDefaultAsync(x => x.Id == id);

            if (topic == null)
            {
                return(this.NotFound());
            }
            if (ModelState.IsValid)
            {
                var user = await this.userManager.GetUserAsync(this.HttpContext.User);

                var now     = DateTime.UtcNow;
                var message = new ForumMessage()
                {
                    Text      = model.Text,
                    CreatorId = user.Id,
                    TopicId   = topic.Id,
                    Created   = now,
                    Modified  = null
                };

                _context.Add(message);
                await _context.SaveChangesAsync();

                this.ViewBag.Topic = topic;
                return(RedirectToAction("Index", "ForumTopics", new { id = topic.Id }));
            }
            return(View(model));
        }
Example #11
0
        public void Forum_Message_New(string[] str)
        {
            if (str.Length < 4)
            {
                return;
            }
            string title   = str[1];
            string author  = str[2];
            string message = str[3];

            string channel = ((WebTVInfo)PageInfo).Channel;
            string path    = Info.address_WebTV + channel + @"\";

            Forum.Forum forum = Channels.FindForum(channel, title);
            if (forum == null)
            {
                return;
            }

            ForumMessage forummessage = new ForumMessage();

            forummessage.Author  = author;
            forummessage.Message = message;
            forum.Add(forummessage);

            Info.SaveFileForum(forum, path + @"\Forum\" + title + Info.extension);

            Add(new MsgJSON_Forum("FORUM", forum));
        }
        // *********************************************************************
        //  UpdateMessageTemplate
        //
        /// <summary>
        /// This method update a message template.
        /// </summary>
        /// <param name="message">Message to be updated</param>
        ///
        // ********************************************************************/
        public static void UpdateMessageTemplate(ForumMessage message)
        {
            // Create Instance of the IDataProviderBase
            IDataProviderBase dp = DataProvider.Instance();

            dp.UpdateMessageTemplate(message);
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,ForumTopicId,ApplicationUserId,Created,Modified,Text")] ForumMessage forumMessage)
        {
            if (id != forumMessage.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(forumMessage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ForumMessageExists(forumMessage.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationUserId"] = new SelectList(_context.Users, "Id", "Id", forumMessage.ApplicationUserId);
            ViewData["ForumTopicId"]      = new SelectList(_context.ForumTopics, "Id", "ApplicationUserId", forumMessage.ForumTopicId);
            return(View(forumMessage));
        }
Example #14
0
        //// GET: Forum/Create
        //public ActionResult Create()
        //{
        //    ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name");
        //    ViewBag.SuggestionId = new SelectList(db.Suggestions, "SuggestionId", "UserId");
        //    ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name");
        //    return View();
        //}

        //// POST: Forum/Create
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> Create([Bind(Include = "ForumId,SuggestionId,DepartmentId,TopicId,DateAdded,LastUpdated,IsActive,UpVotes,DownVotes")] Forum forum)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Forums.Add(forum);
        //        await db.SaveChangesAsync();
        //        return RedirectToAction("Index");
        //    }

        //    ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", forum.DepartmentId);
        //    ViewBag.SuggestionId = new SelectList(db.Suggestions, "SuggestionId", "UserId", forum.SuggestionId);
        //    ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name", forum.TopicId);
        //    return View(forum);
        //}

        //// GET: Forum/Edit/5
        //public async Task<ActionResult> Edit(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Forum forum = await db.Forums.FindAsync(id);
        //    if (forum == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", forum.DepartmentId);
        //    ViewBag.SuggestionId = new SelectList(db.Suggestions, "SuggestionId", "UserId", forum.SuggestionId);
        //    ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name", forum.TopicId);
        //    return View(forum);
        //}

        //// POST: Forum/Edit/5
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> Edit([Bind(Include = "ForumId,SuggestionId,DepartmentId,TopicId,DateAdded,LastUpdated,IsActive,UpVotes,DownVotes")] Forum forum)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Entry(forum).State = EntityState.Modified;
        //        await db.SaveChangesAsync();
        //        return RedirectToAction("Index");
        //    }
        //    ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", forum.DepartmentId);
        //    ViewBag.SuggestionId = new SelectList(db.Suggestions, "SuggestionId", "UserId", forum.SuggestionId);
        //    ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name", forum.TopicId);
        //    return View(forum);
        //}

        // GET: ForumMessages/Edit/5

        public async Task <ActionResult> EditMessage(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ForumMessage forumMessage = await db.ForumMessages.FindAsync(id);

            if (forumMessage == null)
            {
                return(HttpNotFound());
            }

            var editComment = new EditCommentModel
            {
                ForumId        = forumMessage.ForumId,
                ForumMessageId = forumMessage.ForumMessageId,
                Message        = forumMessage.Message
            };

            //ViewBag.ForumId = new SelectList(db.Forums, "ForumId", "ForumId", forumMessage.ForumId);
            //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", forumMessage.UserId);
            return(View(editComment));
        }
Example #15
0
        public async Task <ActionResult> AddComment(AddCommentModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(User.Identity.Name);

                var message = new ForumMessage
                {
                    ForumId        = model.ForumId,
                    ReplyMessageId = null,
                    Message        = model.Comment,
                    UserId         = user.Id
                };

                db.ForumMessages.Add(message);
                await db.SaveChangesAsync();

                return(RedirectToAction("Messages", "Forum", new { id = model.ForumId }));
            }

            //ViewBag.ForumId = new SelectList(db.Forums, "ForumId", "ForumId", forumMessage.ForumId);
            //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", forumMessage.UserId);
            ModelState.AddModelError("Error ", "Please enter a valid comment");
            return(RedirectToAction("Messages", "Forum", new { id = model.ForumId }));
        }
Example #16
0
 public ActionResult Create(int Id, [Bind(Include = "Content")] ForumMessage Data)
 {
     Data.Account = User.Identity.Name;
     Data.AId     = Id;
     service.Insert(Data);
     return(RedirectToAction("Index", new { Id = Id }));
 }
Example #17
0
 public MessageAPIModel(ForumMessage msg)
 {
     Id      = msg.Id;
     Text    = msg.Text;
     User    = new ForumUserAPIModel(msg.User);
     TopicId = msg.Topic.Id;
     Date    = $"{msg.Date.ToShortDateString()} {msg.Date.ToShortTimeString()}";
 }
        public Boolean CanEditMessage(ForumMessage message)
        {
            if (!this.HttpContext.User.Identity.IsAuthenticated)
            {
                return(false);
            }

            return(this.HttpContext.User.IsInRole(ApplicationRoles.Administrators) ||
                   this.userManager.GetUserId(this.httpContextAccessor.HttpContext.User) == message.UserId);
        }
Example #19
0
        public async Task Send(string message, int topicId)
        {
            var user = await _users.GetByEmailAsync(Context.User.Identity.Name);

            var    msg = new ForumMessage(message, topicId, user.Id);
            string error;

            if (_messages.Create(msg, out error, Context.User.Identity.Name))
            {
                await Clients.All.SendAsync($"Receive{topicId}", msg);
            }
        }
Example #20
0
        public void CanChangeForumBody()
        {
            ForumMessage p = new ForumMessage {
                Subject = "Bags", Date = new DateTime(2 / 2 / 2017), Body = "If you have extra's drop them off."
            };

            string body = "wow there where alot of squirels today!";

            p.Body = body;

            Assert.Equal(body, p.Body);
        }
        // ****************************************************************
        // DisplayEditMode
        //
        /// <summary>
        /// Retrieves the values for the title and body from the database
        /// and dispalys them in textboxs for the user to edit
        /// </summary>
        // ****************************************************************
        private void DisplayEditMode()
        {
            // Set the preview to the correct message
            preview.NavigateUrl = Globals.UrlMessage + messageTemplates.SelectedItem.Value;

            // Now populate the subject/body with the appropriate values
            // read in the email template's subject/body
            ForumMessage message = ForumMessages.GetMessage(Convert.ToInt32(messageTemplates.SelectedItem.Value));

            // Set the values for subject/body
            title.Text = message.Title;
            body.Text  = message.Body;
        }
Example #22
0
        public int Update(ForumMessage post)
        {
            if (post.ForumMessageID == 0)
            {
                context.ForumMessages.Add(post);
            }
            else
            {
                context.ForumMessages.Update(post);
            }

            return(context.SaveChanges());
        }
Example #23
0
        // GET: Forum/Delete/5
        public async Task <ActionResult> DeleteMessage(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ForumMessage forumMessage = await db.ForumMessages.FindAsync(id);

            if (forumMessage == null)
            {
                return(HttpNotFound());
            }
            return(View(forumMessage));
        }
Example #24
0
        public bool CreateForumAnswer(ForumMessage forumAnswer)
        {
            bool flag = false;

            try
            {
                _forumMessageRepository.Add(forumAnswer);
                _unitOfWork.Commit();
                flag = true;
            }
            catch { }

            return(flag);
        }
Example #25
0
 public async Task <IActionResult> CreateMessage(ForumMessage message, int id)
 {
     message.TopicId = id;
     message.Author  = HttpContext.User.Identity.Name;
     _msgRepo.AddMessage(message);
     if (await _msgRepo.SaveChangesAsync())
     {
         return(RedirectToAction("ShowTopic", new { ID = id }));
     }
     else
     {
         return(View(new TopicAndMsgsViewModel()));
     }
 }
Example #26
0
        public void AddMessage(ForumMessageModel model)
        {
            var subjId = dBEntities.ForumSubject.Single(x => x.subjectName.Equals(model.SubjectName)).subjectId;
            var subj   = new ForumMessage()
            {
                userid         = model.AuthorId,
                messageContent = model.Content,
                subjectId      = subjId,
                date           = model.Date
            };

            dBEntities.ForumMessage.Add(subj);
            dBEntities.SaveChanges();
        }
Example #27
0
 public async Task <IActionResult> EditMessage(ForumMessage message, int id)
 {
     message.Id          = id;
     message.LastUpdated = DateTime.Now;
     _msgRepo.UpdateMessage(message);
     if (await _msgRepo.SaveChangesAsync())
     {
         return(RedirectToAction("EditMessage", new { ID = id }));
     }
     else
     {
         return(View(new TopicAndMsgsViewModel()));
     }
 }
Example #28
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ForumMessage forumMessage = await db.ForumMessages.FindAsync(id);

            if (forumMessage == null)
            {
                return(HttpNotFound());
            }
            int forumId = forumMessage.ForumId;

            db.ForumMessages.Remove(forumMessage);
            await db.SaveChangesAsync();

            return(RedirectToAction("Messages", new { id = forumId }));
        }
Example #29
0
        public ActionResult Add(ForumMessage message)
        {
            string fileName  = Path.GetFileNameWithoutExtension(message.ImageFile.FileName);
            string extension = Path.GetExtension(message.ImageFile.FileName);

            fileName          = fileName + DateTime.Now.ToString("yy-MM-dd") + extension;
            message.ImagePath = "~/ForumImages/" + fileName;
            fileName          = Path.Combine(Server.MapPath("~/ForumImages/"), fileName);
            message.ImageFile.SaveAs(fileName);
            context.ForumMessages.Add(message);
            context.SaveChanges();
            ModelState.Clear();

            return(RedirectToAction("GetForumPosts"));
        }
        // ****************************************************************
        // UpdateTemplate_Click
        //
        /// <summary>
        /// Logic to handle updating the message in the database when
        /// the user has made changes.
        /// </summary>
        // ****************************************************************
        private void UpdateTemplate_Click(Object sender, EventArgs e)
        {
            ForumMessage message = new ForumMessage();

            message.MessageID = Convert.ToInt32(messageTemplates.SelectedItem.Value);
            message.Title     = title.Text;
            message.Body      = body.Text;

            // update the email template
            ForumMessages.UpdateMessageTemplate(message);

            // Display that we've updated
            status.Visible = true;
            status.Text    = "Message template updated...";
        }
        public string WriteMessage(ForumMessage message)
        {
            string ret = "";
            for (int i = 0; i < message.Level; i++)
                ret += "&nbsp;&nbsp;&nbsp;";
            ret += message.Title + "<br>";
            for (int i = 0; i < message.Level; i++)
                ret += "&nbsp;&nbsp;&nbsp;";
            ret += message.Owner + "<br>";
            for (int i = 0; i < message.Level; i++)
                ret += "&nbsp;&nbsp&nbsp;";
            ret += message.Body + "<br>";

            ret += "&nbsp;&nbsp&nbsp;";
            ret += "<a href=\"createmessage.html";
            ret += "?idFolderParent=0";
            ret += "&idMessageParent=" + message.Id + "\">Responder</a>";

            return ret;
        }
Example #32
0
 private string GetAuthorName(ForumMessage m)
 {
     var user = UserManager.Users.FirstOrDefault(u => u.Id == m.UserId);
     return user != null ? user.UserName : "******";
 }
Example #33
0
        private static ForumMessage DisplayMessage(DataModels.Forum.ForumMessage message)
        {
            try
            {
                ForumMessage me = new ForumMessage();
                me.TopicId = message.Topic.TopicId;
                me.ForumId = message.Topic.Forum.ForumId;
                me.Created = message.Created;
                me.CreatedHumanRelative = RDN.Utilities.Dates.DateTimeExt.RelativeDateTime(message.Created);
                me.Member = new MemberDisplay { TotalForumPostsCount = message.Member.TotalForumPosts, MemberId = message.Member.MemberId, DerbyName = message.Member.DerbyName, };
                if (message.Member.Gender == Convert.ToInt32(GenderEnum.Female))
                    me.Member.Gender = GenderEnum.Female;
                else if (message.Member.Gender == Convert.ToInt32(GenderEnum.Male))
                    me.Member.Gender = GenderEnum.Male;
                else
                    me.Member.Gender = GenderEnum.None;

                if (message.Member.Photos.Count > 0)
                {
                    var photo = message.Member.Photos.OrderByDescending(x => x.Created).Where(x => x.IsPrimaryPhoto == true).FirstOrDefault();
                    if (photo != null)
                    {
                        me.Member.Photos.Add(new PhotoItem(photo.ImageUrl, true, me.Member.DerbyName));
                    }
                }


                if (message.LastModified > new DateTime(2013, 11, 23) || message.Created > new DateTime(2013, 11, 23))
                {
                    me.MessageHTML = message.MessageHTML;
                }
                else if (me.Created < new DateTime(2013, 11, 23))
                {
                    RDN.Library.Util.MarkdownSharp.Markdown markdown = new RDN.Library.Util.MarkdownSharp.Markdown();
                    markdown.AutoHyperlink = true;
                    markdown.AutoNewLines = true;
                    markdown.LinkEmails = true;
                    me.MessageMarkDown = message.MessageHTML;
                    me.MessageHTML = markdown.Transform(HtmlSanitize.FilterHtmlToWhitelist(message.MessageHTML));
                    me.MessageHTML = me.MessageHTML.Replace("</p>", "</p><br/>");
                }

                me.MessageId = message.MessageId;
                me.MessagePlain = message.MessagePlain;

                me.MessageLikeCount = message.MessagesLike.Sum(x => x.TotalCount);
                me.MessageAgreeCount = message.MessagesAgree.Sum(x => x.TotalCount);


                return me;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return null;
        }