public List <OutgoingMessageViewModel> ScrollMoveMessages(Guid messageID, bool Up) { int totalCount = 0; ChatMessageRepository cRepo = new ChatMessageRepository(); var message = cRepo.Get(messageID); var messages = cRepo.GetAll(null, 0, 30, out totalCount, null, (ChatMessageSurrogate u) => Up ? u.ReceivedDate <message.ReceivedDate : u.ReceivedDate> message.ReceivedDate); return(messages.Select(u => (OutgoingMessageViewModel)u).ToList());//.Cast<OutgoingMessageViewModel>().ToList(); }
public static List <OutgoingMessageViewModel> GetInitMessage(Guid lastMessageID) { List <OutgoingMessageViewModel> result = new List <OutgoingMessageViewModel>(); var cRepo = new ChatMessageRepository(); var lastMessage = cRepo.Get(lastMessageID); if (lastMessage != null) { int totalCount = 0; var beforeMessages = cRepo.GetAll(null, 30, 0, out totalCount, "date", (ChatMessageSurrogate u) => u.ReceivedDate < lastMessage.ReceivedDate); var afterMessages = cRepo.GetAll(null, 30, 0, out totalCount, "date", (ChatMessageSurrogate u) => u.ReceivedDate > lastMessage.ReceivedDate); result.AddRange(beforeMessages.Select(u => (OutgoingMessageViewModel)u).ToList()); //beforeMessages.Cast<OutgoingMessageViewModel>()); OutgoingMessageViewModel lastOutgoinMessage = lastMessage; lastOutgoinMessage.LastReadedMessage = true; result.Add(lastOutgoinMessage); result.AddRange(afterMessages.Select(u => (OutgoingMessageViewModel)u).ToList()); } return(result); }
internal static Guid?GetLastMessage() { ChatMessageRepository cRepo = new ChatMessageRepository(); int totalCount = 0; var lastMessmage = cRepo.GetAll(null, 1, 0, out totalCount, "date desc").FirstOrDefault(); if (lastMessmage != null) { return(lastMessmage.ID); } else { return(null); } }