예제 #1
0
 public void CreateMessage(Message message)
 {
     using (var db = new AOEChatEntities())
     {
         db.Messages.Add(message);
         db.SaveChanges();
     }
 }
예제 #2
0
 public static Message GetMessage(int messageId)
 {
     using (var db = new AOEChatEntities())
     {
         Message message = db.Messages.Single(i => i.MessageId == messageId);
         return message;
     }
 }
예제 #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();
     }
 }
예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #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;
     }
 }
예제 #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;
     }
 }