Ejemplo n.º 1
0
        public static bool CreateMessage(DBO.Message message)
        {
            try
            {
                using (MeditateBookEntities bdd = new MeditateBookEntities())
                {
                    T_Message newMessage = new T_Message()
                    {
                        content     = message.Content,
                        date        = message.Date,
                        id_receiver = message.IdReceiver,
                        id_sender   = message.IdSender,
                        isSeen      = message.IsSeen
                    };

                    bdd.T_Message.Add(newMessage);
                    bdd.SaveChanges();
                    return(true);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return(false);
            }
        }
Ejemplo n.º 2
0
 public static bool DoesUserHaveNewMessage(int user_id)
 {
     try
     {
         using (MeditateBookEntities bdd = new MeditateBookEntities())
         {
             T_Message message = bdd.T_Message.Where(x => x.id_receiver == user_id && x.isSeen == false).FirstOrDefault();
             return(message != null);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(false);
     }
 }
Ejemplo n.º 3
0
 public static bool UpdateMessage(DBO.Message message)
 {
     try
     {
         using (MeditateBookEntities bdd = new MeditateBookEntities())
         {
             T_Message oldMessage = bdd.T_Message.Where(x => x.id == message.Id).FirstOrDefault();
             oldMessage.content     = message.Content;
             oldMessage.date        = message.Date;
             oldMessage.id_receiver = message.IdReceiver;
             oldMessage.id_sender   = message.IdSender;
             oldMessage.isSeen      = message.IsSeen;
             bdd.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(false);
     }
 }