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