Exemplo n.º 1
0
        public static ChatMessageRepository GetChatMessageRepository(IUnitOfWork unitOfWork)
        {
            var repository = new ChatMessageRepository();

            repository.UnitOfWork = unitOfWork;
            return(repository);
        }
Exemplo n.º 2
0
        public static ChatMessageRepository GetChatMessageRepository()
        {
            var repository = new ChatMessageRepository();

            repository.UnitOfWork = GetUnitOfWork();
            return(repository);
        }
Exemplo n.º 3
0
 public MessageSentMessageHandler(
     ChatHandler chatHandler,
     ChatMessageRepository chatMessageRepository)
 {
     _chatHandler           = chatHandler;
     _chatMessageRepository = chatMessageRepository;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Kullancının gönderisi başka bir kullanıcı tarafından beğenildiğine bildirim gönderir.
        /// </summary>
        /// <param name="userid">Bildirim gönderilecek kullanıcının unique id si.</param>
        /// <param name="message">Bildirim gönderen kullanıcın adı soyadı varsa mesajı</param>
        /// <returns></returns>
        public Task SendMessage(string userid, string recieverUserId, string messageText)
        {
            var user    = _db.Users.Find(userid);
            var message = new MessageViewModel
            {
                DateSend         = DateTime.Now,
                UserId           = userid,
                RecieverUserId   = recieverUserId,
                MessageText      = messageText,
                UserProfilePhoto = user.UserProfilePhoto,
                UserName         = user.UserFirstName,
                UserSurname      = user.UserSurname
            };
            ChatMessageRepository repository = new ChatMessageRepository();

            repository.Add(message);
            dynamic client = null;

            foreach (var connectionId in _connections.GetConnections(recieverUserId.ToString()))
            {
                client = Clients.Client(connectionId);
            }

            return(client.recieveMessage(message));
        }
Exemplo n.º 5
0
        private void updateChat()
        {
            var messages = ChatMessageRepository.GetChatMessagesForPeriod(chatUoW, chatUoW.Root, showMessagePeriod);

            TextBuffer tempBuffer = new TextBuffer(textTags);
            TextIter   iter       = tempBuffer.EndIter;
            DateTime   maxDate    = default(DateTime);

            foreach (var message in messages)
            {
                if (message.DateTime.Date != maxDate.Date)
                {
                    tempBuffer.InsertWithTagsByName(
                        ref iter,
                        String.Format("\n{0:D}", message.DateTime.Date),
                        "date");
                }
                var userName = message.IsServerNotification ? ChatService.UserNameOfServer : message.SenderName;
                tempBuffer.InsertWithTagsByName(
                    ref iter,
                    string.Format("\n({0:t}) {1}: ", message.DateTime, userName),
                    getUserTag(userName));
                tempBuffer.Insert(ref iter, message.Message);
                if (message.DateTime > maxDate)
                {
                    maxDate = message.DateTime;
                }
            }
            textViewChat.Buffer = tempBuffer;
            updateTitle();
            //ChatCallbackObservable.GetInstance().NotifyChatUpdate(chatUoW.Root.Id, this);
            scrollToEnd();
        }
 public void LoadLocalPreviousMessages()
 {
     try
     {
         loadList = false;
         paginationModel.SkipRecords += 30;
         if (chatConversation != null)
         {
             int PreviousListCount = ListChatsCon.Values.Sum(list => list.Count);
             ListChatsCon = ChatMessageRepository.GetChatMessagesForPageIndex(paginationModel, chatConversation.ChatId);
             int CurrentListCount = ListChatsCon.Values.Sum(list => list.Count);
             if (ListChatsCon != null && ListChatsCon.Count > 0)
             {
                 mAdapter = new PrivateMessgeAdapter(this, ListChatsCon);
                 mRecyclerView.SetAdapter(mAdapter);
                 mAdapter.NotifyDataSetChanged();
                 mRecyclerView.ScrollToPosition(CurrentListCount - PreviousListCount - 2);
                 loadList = true;
             }
         }
     }
     catch (Exception e)
     {
         Crashes.TrackError(e);
     }
 }
Exemplo n.º 7
0
 public ChatController(ChatUserSessionRepository chatUserSessionRepository, ChatSessionRepository chatSessionRepository, ChatMessageRepository chatMessageRepository, IUserSession userSession)
 {
     ChatMessageRepository     = chatMessageRepository;
     ChatSessionRepository     = chatSessionRepository;
     ChatUserSessionRepository = chatUserSessionRepository;
     UserSession = userSession;
 }
Exemplo n.º 8
0
        public Guid?SendMessage(IncomingMessageViewModel message)
        {
            try
            {
                int    userID               = HttpContext.Current.User.Identity.GetUserId <int>();
                string nickName             = HttpContext.Current.User.Identity.NickName();
                ChatMessageRepository cRepo = new ChatMessageRepository();
                var messageSurrogate        = cRepo.CreateNewInstance(message.Message);
                //messageSurrogate.AttachType = (byte)message.AttachType;

                messageSurrogate.ReplyToMessageID = message.ReplyToMessageID;
                messageSurrogate.UserID           = userID;
                messageSurrogate.ReceivedDate     = DateTime.Now;
                cRepo.Save(messageSurrogate);
                OutgoingMessageViewModel outgoingMessage = messageSurrogate;
                Clients.All.IncomingMessage(outgoingMessage);
                //if ((AttachType)messageSurrogate.AttachType != AttachType.None)
                //{
                //    this.Clients.Caller.StartMessageFileUpload(messageSurrogate.ID);
                //}
                return(messageSurrogate.ID);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        private async void _objChatSignalRService_OnMessageReceived(object sender, ChatMessageViewModel e)
        {
            try
            {
                if (e.ChatMessageId != 0)
                {
                    var chatmessage = ChatMessageRepository.CheckMessage(e.ChatMessageId);
                    if (chatmessage == null)
                    {
                        var savedMessages    = ChatMessageRepository.SaveChatMessage(e, e.ChatId);
                        var chatConversation = ChatConversationRepository.GetConversationIdbyChatId(savedMessages.ChatId);
                        if (e.Attachments.Count > 0)
                        {
                            savedMessages.MessageText = (string.IsNullOrEmpty(savedMessages.MessageText))? e.Attachments[e.Attachments.Count - 1].Type : savedMessages.MessageText;
                        }
                        chatConversation = ChatConversationRepository.UpdateChatLastMessage(chatConversation.id, savedMessages.MessageText, "");
                        if (chatConversation != null)
                        {
                            Activity.RunOnUiThread(() =>
                            {
                                MessageReceived(chatConversation, "OldChat");
                            });
                        }

                        await _objChatSignalRService.SendUpdate(chatConversation.ContactId.ToString(), e, "ChatList");
                    }
                }
            }
            catch (Java.Lang.Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Exemplo n.º 10
0
 public void CreateChatMessage(ChatMessageServiceView message)
 {
     try
     {
         if (SPUtility.ValidateFormDigest())
         {
             IChatMessageRepository repo = new ChatMessageRepository();
             repo.Create(
                 new ChatMessage()
             {
                 Title     = "",
                 Message   = message.Message,
                 Receivers = (message.Receivers != null) ? message.Receivers.Select(p => new Contact()
                 {
                     ID = p.ID
                 }).ToArray() : null
             }
                 );
         }
         else
         {
             Config.WriteException(new Exception(Language.AccessDenied));
             WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.Unauthorized;
             WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.UserNotValidated;
         }
     }
     catch (Exception ex)
     {
         Config.WriteException(ex);
         WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.InternalServerError;
         WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.CreateChatMessageError;
     }
 }
Exemplo n.º 11
0
        public void MessageReaded(Guid messageID)
        {
            int userid   = Context.User.Identity.GetUserId <int>();
            var nickname = Context.User.Identity.NickName();
            ChatMessageRepository cRepo = new ChatMessageRepository();
            var message = cRepo.Get(messageID);

            if (message != null)
            {
                if (!message.ReadedUsers.Any(u => u.ID == userid))
                {
                    //var userManager = UserManager;
                    message.ReadedUsers.Add(new UserSurrogate {
                        ID = userid, NickName = Context.User.Identity.NickName()
                    });
                    cRepo.Save(message);
                    var user = UserManager.Users.Where(u => u.Id == userid).SingleOrDefault();
                    user.LastReadedMessage = messageID;
                    UserManager.Update(user);
                }
                Clients.Others.MessageReaded(new UserViewModel {
                    UserID = userid, Name = nickname
                }, messageID);
            }
        }
Exemplo n.º 12
0
        public List <MessageDTO> AndroidGetChatMessages(string authKey, int days)
        {
            try {
                using (var uow = UnitOfWorkFactory.CreateWithoutRoot($"[CS]Получение сообщений чата"))
                {
                    var driver = EmployeeRepository.GetDriverByAuthKey(uow, authKey);
                    if (driver == null)
                    {
                        return(null);
                    }

                    var chat = ChatRepository.GetChatForDriver(uow, driver);
                    if (chat == null)
                    {
                        return(null);
                    }
                    var messages     = new List <MessageDTO>();
                    var chatMessages = ChatMessageRepository.GetChatMessagesForPeriod(uow, chat, days);
                    foreach (var m in chatMessages)
                    {
                        messages.Add(new MessageDTO(m, driver));
                    }
                    return(messages);
                }
            } catch (Exception e) {
                logger.Error(e);
                return(null);
            }
        }
Exemplo n.º 13
0
        private async void LoadServerMessagesUpto(DateTime date)
        {
            var unixTimeStamp = CommonHelper.DateTimeToUnixTimestamp(date.AddSeconds(-1));

            try
            {
                //BTProgressHUD.Show("Loading messages..", maskType: ProgressHUD.MaskType.Black);
                await Task.Run(async() =>
                {
                    var result = await new ChatService().GetChatMessagesUptoId(contactViewModel.ContactId, unixTimeStamp);
                    if (result.Status == 1)
                    {
                        var chatMessagelist = JsonConvert.DeserializeObject <List <ChatMessageViewModel> >(result.Response.ToString());

                        var savedMessages = ChatMessageRepository.SaveChatMessages(chatMessagelist, chatConversation.ChatId);

                        InvokeOnMainThread(() =>
                        {
                            LoadLocalLatestMessages();
                        });
                    }
                });
            }
            catch (Exception e)
            {
                //Crashes.TrackError(e);
            }
        }
Exemplo n.º 14
0
        public System.IO.Stream ExportHistory(string SenderID)
        {
            StringBuilder result = new StringBuilder();

            try
            {
                IChatMessageRepository repo = new ChatMessageRepository();
                var messages = repo.GetConversationHistory(SPContext.Current.Web.CurrentUser.ID, Int32.Parse(SenderID));
                result.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
                result.Append("<ChatMessages>");
                foreach (ChatMessage msg in messages)
                {
                    result.Append(msg.GetXml());
                }
                result.Append("</ChatMessages>");
            }
            catch (Exception ex)
            {
                Config.WriteException(ex);
                WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.InternalServerError;
                WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.CreateChatMessageError;
            }
            WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
            return(new MemoryStream(Encoding.UTF8.GetBytes(result.ToString())));;
        }
Exemplo n.º 15
0
        private void _objChatSignalRService_OnGetUpdateStatus(object sender, ChatMessageViewModel e)
        {
            try
            {
                if (e.ChatMessageId != 0)
                {
                    lock (thisLock)
                    {
                        var chatmessage = ChatMessageRepository.CheckMessage(e.ChatMessageId);
                        if (chatmessage != null)
                        {
                            var savedMessages = ChatMessageRepository.updateChatMessage(e);

                            InvokeOnMainThread(() =>
                            {
                                LoadLocalLatestMessages();
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Exemplo n.º 16
0
        public void LoadLocalLatestMessages()
        {
            try
            {
                loadList = false;

                if (chatConversation != null)
                {
                    ListChatsCon = ChatMessageRepository.GetChatMessagesForPageIndex(paginationModel, chatConversation.ChatId);

                    if (ListChatsCon != null && ListChatsCon.Count > 0)
                    {
                        mAdapter = new PrivateMessgeAdapter(this, ListChatsCon);
                        mRecyclerView.SetAdapter(mAdapter);
                        mAdapter.NotifyDataSetChanged();
                        mRecyclerView.ScrollToPosition(mAdapter.ItemCount - 1);
                        loadList = true;
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Exemplo n.º 17
0
 private void _objChatSignalRService_OnGetUpdateStatus(object sender, ChatMessageViewModel e)
 {
     try
     {
         if (e.ChatMessageId != 0)
         {
             var chatmessage = ChatMessageRepository.CheckMessage(e.ChatMessageId);
             if (chatmessage != null)
             {
                 var savedMessages    = ChatMessageRepository.updateChatMessage(e);
                 var chatConversation = ChatConversationRepository.GetConversationIdbyChatId(savedMessages.ChatId);
                 if (chatConversation != null)
                 {
                     Activity.RunOnUiThread(() =>
                     {
                         MessageReceived(chatConversation, "OldChat");
                     });
                 }
             }
         }
     }
     catch (Java.Lang.Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
Exemplo n.º 18
0
        private async void _objChatSignalRService_OnMessageReceived(object sender, ChatMessageViewModel e)
        {
            try
            {
                if (e.ChatMessageId != 0)
                {
                    lock (thisLock)
                    {
                        var chatmessage = ChatMessageRepository.CheckMessage(e.ChatMessageId);
                        if (chatmessage == null)
                        {
                            if (contactViewModel.ChatId == e.ChatId)
                            {
                                e.IsRead = true;
                            }
                            var savedMessages = ChatMessageRepository.SaveChatMessage(e, e.ChatId);
                            InvokeOnMainThread(() =>
                            {
                                LoadLocalLatestMessages();
                            });

                            UpdateChatMessage(chatConversation.ContactId.ToString(), e, "Private");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Exemplo n.º 19
0
        public void LoadLocalLatestMessages()
        {
            try
            {
                loadList = false;

                if (chatConversation != null)
                {
                    ListChatsCon = ChatMessageRepository.GetChatMessagesForPageIndex(paginationModel, chatConversation.ChatId);

                    if (ListChatsCon != null && ListChatsCon.Count > 0)
                    {
                        tblChat.TableFooterView = new UIView();

                        chatViewContarollerSource = new ChatViewContarollerSource(ListChatsCon, this);

                        tblChat.Source    = chatViewContarollerSource;
                        tblChat.RowHeight = 40;
                        tblChat.ReloadData();
                        ScrollToBottom(true);
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Exemplo n.º 20
0
        protected void OnButtonOkClicked(object sender, EventArgs e)
        {
            var currentEmployee = EmployeeRepository.GetEmployeeForCurrentUser(UoW);
            var service         = new ChannelFactory <IChatService>(
                new BasicHttpBinding(),
                ChatMain.ChatServiceUrl).CreateChannel();

            var  accessToLogisticChat = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("logistican");
            var  unreadedMessages     = ChatMessageRepository.GetUnreadedChatMessages(UoW, currentEmployee, accessToLogisticChat);
            bool needCommit           = false;

            foreach (var recipient in Recipients)
            {
                service.SendMessageToDriver(
                    currentEmployee.Id,
                    recipient.Id,
                    textviewMessage.Buffer.Text
                    );
                var unreaded = unreadedMessages.FirstOrDefault(x => x.EmployeeId == recipient.Id);
                if (unreaded == null)
                {
                    var chat = ChatRepository.GetChatForDriver(UoW, recipient);
                    if (chat != null)
                    {
                        chat.UpdateLastReadedTime(currentEmployee);
                        UoW.Save(chat);
                        needCommit = true;
                    }
                }
                if (needCommit)
                {
                    UoW.Commit();
                }
            }
        }
Exemplo n.º 21
0
 public UnitOfWork(AppDbContext context)
 {
     _context              = context;
     ChatRepository        = new ChatRepository(_context);
     UserChatRepository    = new UserChatRepository(_context);
     ChatMessageRepository = new ChatMessageRepository(_context);
     MessageRepository     = new MessageRepository(_context);
 }
Exemplo n.º 22
0
        public static OutgoingMessageViewModel GetMessage(Guid messageID)
        {
            ChatMessageRepository cRepo     = new ChatMessageRepository();
            var messageSurrogate            = cRepo.Get(messageID);
            OutgoingMessageViewModel result = messageSurrogate;

            return(result);
        }
Exemplo n.º 23
0
        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();
        }
Exemplo n.º 24
0
        private ChatCallbackObservable(int employeeId)
        {
            observers        = new List <IChatCallbackObserver>();
            employeeUoW      = UnitOfWorkFactory.CreateForRoot <Employee>(employeeId, $"[CS]Слежение за чатами");
            unreadedMessages = ChatMessageRepository.GetLastChatMessages(employeeUoW, employeeUoW.Root);

            //Initiates new message check every 30 seconds.
            timerId = GLib.Timeout.Add(refreshInterval, new GLib.TimeoutHandler(refresh));
        }
Exemplo n.º 25
0
 public HomeController(
     ILogger <HomeController> logger,
     ChatChannelRepository chatChannelRepository,
     ChatMessageRepository chatMessageRepository)
 {
     _logger = logger;
     _chatChannelRepository = chatChannelRepository;
     _chatMessageRepository = chatMessageRepository;
 }
Exemplo n.º 26
0
        public ChatMessageListResult ChatMessages(int SenderID)
        {
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache");
            ChatMessageListResult result = null;

            try
            {
                if (SPUtility.ValidateFormDigest())
                {
                    IChatMessageRepository repo = new ChatMessageRepository();
                    // get the users timezone
                    SPTimeZone zone = SPContext.Current.Web.RegionalSettings.TimeZone;
                    if (SPContext.Current.Web.CurrentUser.RegionalSettings != null)
                    {
                        SPRegionalSettings rs = SPContext.Current.Web.CurrentUser.RegionalSettings;
                        zone = rs.TimeZone;
                    }
                    result = new ChatMessageListResult()
                    {
                        LastRequested = DateTime.Now.ToString(),
                        ChatMessages  = repo.GetUnReadByUserIDAndSenderID(SPContext.Current.Web.CurrentUser.ID, SenderID)
                                        .Select(m => new ChatMessageServiceView()
                        {
                            ID              = m.ID,
                            Created         = (zone.UTCToLocalTime(m.Created)).ToString(),
                            CreatedDateOnly = (zone.UTCToLocalTime(m.Created).Date).ToShortDateString(),
                            CreatedTimeOnly = (zone.UTCToLocalTime(m.Created)).ToString("HH:mm"),
                            CreatedBy       = m.CreatedBy.Name,
                            Message         = m.Message,
                            Receivers       = m.Receivers.Select(r => new ChatContactServiceView()
                            {
                                ID       = r.ID,
                                Name     = r.Name,
                                Username = r.Username.Split('\\').Last()
                            }).ToArray()
                        }).ToArray()
                    };
                    if (result.ChatMessages.Length > 0)
                    {
                        repo.SetChatMessagesRead(result.ChatMessages.Select(i => i.ID).ToArray());
                    }
                }
                else
                {
                    WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.Unauthorized;
                    WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.UserNotValidated;
                }
            }
            catch (Exception ex)
            {
                Config.WriteException(ex);
                WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.InternalServerError;
                WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.GetMessagesError;
            }
            return(result);
        }
Exemplo n.º 27
0
        public PendingMessageView[] PendingMessageCounts(int messageTimeOut)
        {
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache");
            PendingMessageView[] result = new PendingMessageView[0];
            try
            {
                if (SPUtility.ValidateFormDigest())
                {
                    // set the current user to online
                    IContactRepository crepo = new ContactRepository();
                    crepo.SetContactOnline(Language.SMUGroupName, SPContext.Current.Web.CurrentUser.ID);

                    // get the user statuses
                    IGroupRepository grepo = new GroupRepository();
                    var group       = grepo.GetGroup(Language.SMUGroupName);
                    var contactList = crepo.GetAllFromGroup(group, messageTimeOut);

                    // get the pending messages
                    IChatMessageRepository repo = new ChatMessageRepository();
                    var messages = repo.GetPendingMessageByUser(SPContext.Current.Web.CurrentUser.ID);

                    result = (from m in messages
                              group m by m.CreatedBy.ID into g
                              select new PendingMessageView()
                    {
                        ID = g.Key,
                        IsOnline = false,
                        Count = g.Count()
                    }).ToArray();

                    // get the pending information
                    result = (from i in contactList
                              where i.ID != SPContext.Current.Web.CurrentUser.ID
                              select new PendingMessageView()
                    {
                        ID = i.ID,
                        IsOnline = i.IsOnline,
                        Count =
                            (result.Any(p => p.ID == i.ID) ?
                             result.First(p => p.ID == i.ID).Count : 0)
                    }).ToArray();
                }
                else
                {
                    WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.Unauthorized;
                    WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.UserNotValidated;
                }
            }
            catch (Exception ex)
            {
                Config.WriteException(ex);
                WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.InternalServerError;
                WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.GetMessagesError;
            }
            return(result);
        }
Exemplo n.º 28
0
        public ActionResult LoadMessagesBetweenUsers(string targetUserId)
        {
            if (String.IsNullOrEmpty(targetUserId))
            {
                return(null);
            }
            var currentUserId = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();
            var currentUser   = _db.Users.Find(currentUserId);
            ChatMessageRepository repository = new ChatMessageRepository();

            ViewBag.currentUserId = currentUser.Id;
            return(PartialView("MessageLoader", repository.GetAllMessagesBetweenUsers(currentUser.Id, targetUserId)));
        }
Exemplo n.º 29
0
        private bool refresh()
        {
            var tempUnreadedMessages = ChatMessageRepository.GetLastChatMessages(employeeUoW, employeeUoW.Root);

            foreach (var item in tempUnreadedMessages)
            {
                if (!unreadedMessages.ContainsKey(item.Key) || unreadedMessages[item.Key] != item.Value)
                {
                    NotifyChatUpdate(item.Key);
                }
            }
            unreadedMessages = tempUnreadedMessages;
            return(true);
        }
Exemplo n.º 30
0
        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);
            }
        }
 private IChatMessageRepository GetRepositoryWithEnrolledUnitOfWork()
 {
     IChatMessageRepository repository = new ChatMessageRepository(WorkUnit);
     return repository;
 }