/// <summary>
 /// Create a new Message object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="contenu">Initial value of the Contenu property.</param>
 /// <param name="dateCreation">Initial value of the DateCreation property.</param>
 /// <param name="createurId">Initial value of the CreateurId property.</param>
 /// <param name="topicId">Initial value of the TopicId property.</param>
 public static Message CreateMessage(global::System.Int32 id, global::System.String contenu, global::System.DateTime dateCreation, global::System.Int32 createurId, global::System.Int32 topicId)
 {
     Message message = new Message();
     message.Id = id;
     message.Contenu = contenu;
     message.DateCreation = dateCreation;
     message.CreateurId = createurId;
     message.TopicId = topicId;
     return message;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Messages EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMessages(Message message)
 {
     base.AddObject("Messages", message);
 }
        public ActionResult WriteMessage(MessageModel messageModel,int reciverID)
        {
            if (!ModelState.IsValid) {

                return View();
            }
            var currentlyLoggedInUserId = (int)Session["UserId"];
            var message = new Message();
            message.ReciverID = reciverID;
            message.SenderID = currentlyLoggedInUserId;
            message.TheMessage = messageModel.Message;
            message.Subject = messageModel.Subject;
            message.Date = DateTime.Now;
            MessageRepository.SendMessage(message);
            return RedirectToAction("VisitProfile", "Profile", new { userId = reciverID });
        }