public MessageModel(Message msg)
 {
     id = msg.msg_id;
     body = msg.message_body;
     //time_elapsed_since = getDateSince(msg.date_posted);
     date_posted = TimeZoneInfo.ConvertTimeFromUtc(msg.date_posted, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
     posted_by = new PosterModel(msg.User);
 }
        public ActionResult createMessage(MessageModel message)
        {
            OnlineChatDBEntities db = new OnlineChatDBEntities();
            Message new_message = new Message();
            new_message.message_body = message.body;
            new_message.date_posted = DateTime.UtcNow;

            String username = HttpContext.Session["username"].ToString();
            new_message.fk_poster_id = db.Users.Where(u => u.username == username).FirstOrDefault().user_id;

            db.Messages.Add(new_message);
            db.SaveChanges();

            message.id = new_message.msg_id;
            message.posted_by.username = username;
            message.date_posted = new_message.date_posted;
            //message.time_elapsed_since = MessageModel.getDateSince(new_message.date_posted);

            return Json(message, JsonRequestBehavior.AllowGet);
        }