Example #1
0
            /// <summary>
            /// Marks an message as read.
            /// </summary>
            /// <param name="message">The message to be marked</param>
            /// <returns></returns>
            public static bool MarkMessageRead(Database.Entity.RemindMeMessages message)
            {
                try
                {
                    ReadMessages msg = new ReadMessages();
                    msg.ReadMessageId = message.Id;
                    msg.MessageText   = message.Message;
                    msg.ReadDate      = message.DateOfCreation.Value.ToString();

                    using (RemindMeDbEntities db = new RemindMeDbEntities())
                    {
                        if (db.ReadMessages.Count() > 0)
                        {
                            msg.Id = db.ReadMessages.Max(i => i.Id) + 1;
                        }
                        else
                        {
                            msg.Id = 0;
                        }

                        db.ReadMessages.Add(msg);
                        db.SaveChanges();
                        db.Dispose();
                        return(true);
                    }
                }
                catch
                {
                    return(false);
                }
            }
Example #2
0
        /// <summary>
        /// Gets the RemindMe messages from the database, sent by the creator of RemindMe
        /// </summary>
        public static Database.Entity.RemindMeMessages GetRemindMeMessageById(int id)
        {
            //Don't do anything without internet
            if (!BLIO.HasInternetAccess())
            {
                return(null);
            }

            Data_Access_Layer.RemindMeMessages dbObject = DLOnlineDatabase.GetRemindMeMessageById(id);

            if (dbObject == null)
            {
                return(null);
            }

            Database.Entity.RemindMeMessages message = new Database.Entity.RemindMeMessages();

            message.Id = dbObject.Id;
            message.MeantForSpecificVersion = dbObject.MeantForSpecificVersion;
            message.Message = dbObject.Message;
            message.NotificationDuration = dbObject.NotificationDuration;
            message.NotificationOnTop    = dbObject.NotificationOnTop;
            message.NotificationType     = dbObject.NotificationType;
            message.ReadByAmountOfUsers  = dbObject.ReadByAmountOfUsers;
            message.DateOfCreation       = dbObject.DateOfCreation;

            return(message);
        }