コード例 #1
0
ファイル: MessagePlus.cs プロジェクト: remimarenco/BindedIn
        public MessagePlus(message m)
        {
            this.isRead = m.isRead;
            this.id = m.id;
            this.date = String.Format("{0:dd/MM/yyyy}", m.date);
            this.sender = m.sender;
            this.recipient = m.recipient;
            this.@object = m.@object;
            this.message1 = m.message1;

            UserProfile up = UserProfile.GetUserProfile(UserService.GetUtilisateurById(this.sender).UserName);
            this.senderName = up.FirstName + " " + up.LastName;

            up = UserProfile.GetUserProfile(UserService.GetUtilisateurById(this.recipient).UserName);
            this.recipientName = up.FirstName + " " + up.LastName;
        }
コード例 #2
0
        //renvoie le message corespondant à l' id passé en parametre si l'id ne corespond à aucun message on renvoit null
        public static message GetMessageById(int messageId)
        {
            bindedinEntities bie = SingletonEntities.Instance;
            message messageReturn = new message();

            // on recupere tous les messages
            var search = from m in bie.messages
                         where m.id.Equals(messageId)
                         select m;
            int i = 0;
            foreach (message message in search.ToList())
            {
                i++;
                messageReturn = message;
            }
            if (i == 0)
            {
                return null;
            }

            return messageReturn;
        }
コード例 #3
0
        //envoit un message
        public static void SendMessage(Guid sender, Guid recipient, string obj, string me)
        {
            bindedinEntities bie = SingletonEntities.Instance;

            //on creait un nouveau message
            message m = new message();

            m.sender = sender;
            m.recipient = recipient;
            m.@object = obj;
            m.message1 = me;
            m.isRead = 0;
            m.isRemovedSender = 0;
            m.isRemovedRecipient = 0;
            m.date = DateTime.Now;

            //on sauvegarde le message dans la base
            bie.messages.AddObject(m);
            bie.SaveChanges();
        }
コード例 #4
0
        //renvoit tous les messages envoyés d'un utilisateur
        public static List<message> GetMessageBySenderId(Guid senderId)
        {
            bindedinEntities bie = SingletonEntities.Instance;
            message messageReturn = new message();

            // on recupere les messages
            var search = from m in bie.messages
                         where m.sender==senderId && m.isRemovedSender.Equals(0)
                         orderby m.date descending
                         select m;

            return search.ToList();
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //on vérifie si un utilisteur est connecté
            if (User.Identity.IsAuthenticated)
            {
                //si un id est passé en parametre on affiche le message
                if (Request.Params["id"] != null)
                {
                    //on recupere le message
                    m = MessageService.GetMessageById(Convert.ToInt16(Request.Params["id"]));

                    if (m != null)
                    {

                        if (User.Identity.Name == UserService.GetUtilisateurById(m.sender).UserName || User.Identity.Name == UserService.GetUtilisateurById(m.recipient).UserName)
                        {
                            if (User.Identity.Name == UserService.GetUtilisateurById(m.recipient).UserName)
                            {
                                //on passe le message a "lu"
                                MessageService.ReadMessage(m.id);
                            }

                            //on recupre le username a partir d'un guid
                            string username = UserService.GetUtilisateurById(m.sender).UserName;

                            //on recupere le userprofile a partir du username
                            UserProfile u = UserProfile.GetUserProfile(username);

                            //on remplit le destinataire
                            destinataireM.Text = u.FirstName + " " + u.LastName;

                            //on remplit le champ objet
                            objectM.Text = m.@object;

                            //on remplit le corps du message
                            message.Text = m.message1;

                            // Date
                            dateMessage.InnerText = String.Format("{0:dd MMMM yyyy}", m.date);

                            //affichage de l'image
                            string uId = m.sender.ToString();
                            ImageProfile.ImageUrl = "/ShowImage.ashx?iduser="******"&tmp=" + DateTime.Now;

                            //on remplit les liens
                            lienDestinataire1.HRef = "Profil.aspx?id=" + u.UserName;
                            lienDestinataire2.HRef = "Profil.aspx?id=" + u.UserName;
                        }
                        else
                        {
                            errorMessage("Vous n'avez pas acces à ce message");
                        }

                    }
                    else
                    {
                        errorMessage("Aucun message correspondant");
                    }

                }
                else
                {
                    errorMessage("Aucun message correspondant");
                }
            }
            else
            {
                errorMessage("Vous devez vous connecter");
            }
        }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
 /// <summary>
 /// Create a new message object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="recipient">Initial value of the recipient property.</param>
 /// <param name="sender">Initial value of the sender property.</param>
 /// <param name="object">Initial value of the object property.</param>
 /// <param name="message1">Initial value of the message1 property.</param>
 /// <param name="date">Initial value of the date property.</param>
 /// <param name="isRead">Initial value of the isRead property.</param>
 /// <param name="isRemovedRecipient">Initial value of the isRemovedRecipient property.</param>
 /// <param name="isRemovedSender">Initial value of the isRemovedSender property.</param>
 public static message Createmessage(global::System.Int32 id, global::System.Guid recipient, global::System.Guid sender, global::System.String @object, global::System.String message1, global::System.DateTime date, global::System.Int32 isRead, global::System.Int32 isRemovedRecipient, global::System.Int32 isRemovedSender)
 {
     message message = new message();
     message.id = id;
     message.recipient = recipient;
     message.sender = sender;
     message.@object = @object;
     message.message1 = message1;
     message.date = date;
     message.isRead = isRead;
     message.isRemovedRecipient = isRemovedRecipient;
     message.isRemovedSender = isRemovedSender;
     return message;
 }