Exemple #1
0
 public void CreateMessage(Message message)
 {
     using (var db = new AOEChatEntities())
     {
         db.Messages.Add(message);
         db.SaveChanges();
     }
 }
Exemple #2
0
 public static Message GetMessage(int messageId)
 {
     using (var db = new AOEChatEntities())
     {
         Message message = db.Messages.Single(i => i.MessageId == messageId);
         return message;
     }
 }
Exemple #3
0
 public void UpdateMessage(long messageId, string messageText)
 {
     using (var db = new AOEChatEntities())
     {
         Message m = db.Messages.Where(i => i.MessageId == messageId).SingleOrDefault();
         m.MessageText = messageText;
         db.SaveChanges();
     }
 }
Exemple #4
0
        public static void DeleteAllMessages()
        {
            using (var db = new AOEChatEntities())
            {
                List<Message> messages = db.Messages.ToList();

                foreach (var t in messages)
                {
                    db.Messages.Remove(t);
                }

                db.SaveChanges();
            }
        }
Exemple #5
0
        public static void CreateMessage(int chatUserId, string messageText, float gpsXCoord, float gpsYCoord)
        {
            using (var db = new AOEChatEntities())
            {
                Message m = new Message();
                m.ChatUserId = chatUserId;
                m.MessageText = messageText;
                m.GpsXCoord = gpsXCoord;
                m.GpsYCoord = gpsYCoord;

                db.Messages.Add(m);

                db.SaveChanges();
            }
        }
Exemple #6
0
        public static void DeletePastMessages()
        {
            DateTime startDateTime = DateTime.Now.AddDays(-2);

            using (var db = new AOEChatEntities())
            {
                List<Message> messages = db.Messages.Where(i => i.TimeSent <= startDateTime).ToList();
                //List<Message> messages = db.Messages.ToList();

                foreach (var t in messages)
                {
                    db.Messages.Remove(t);
                }

                db.SaveChanges();
            }
        }
Exemple #7
0
 public static IList<Message> GetMessages()
 {
     using (var db = new AOEChatEntities())
     {
         List<Message> messages = db.Messages.ToList();
         return messages;
         //return  AutoMapper.Mapper.Map< System.Data.Entity.DbSet<Locum>, IList<AllLocums.Web.Models.LocumModel>>(locums);
         //return null;
     }
 }
Exemple #8
0
 public static IList<Message> GetMessagesForUser(int chatUserId)
 {
     using (var db = new AOEChatEntities())
     {
         List<Message> messages = db.Messages.Where(i => i.ChatUserId == chatUserId).ToList();
         return messages;
     }
 }