Exemple #1
0
 public IEnumerable <Message> GetMessages(Guid id, Guid profileId)
 {
     try
     {
         _messagesRepository.CheckUndestroyedMessages(id);
         var list = _messagesRepository.GetMessages(id).ToList();
         list.Sort((one, two) => one.Date.CompareTo(two.Date));
         foreach (var message in list)
         {
             if (!message.IsRead && profileId != message.ProfileId)
             {
                 _messagesRepository.UpdateMessageRead(message.MessageId);
             }
             if (profileId != message.ProfileId)
             {
                 _messagesRepository.Destroy(message);
             }
         }
         return(list);
     }
     catch (SqlException exception)
     {
         var response = new HttpResponseMessage(HttpStatusCode.NotFound)
         {
             Content = new StringContent(exception.Message)
         };
         throw new HttpResponseException(response);
     }
 }
 public ApiModel.PagedResult <MessageSummary> GetSummaries(string sortColumn = "receivedDate", bool sortIsDescending = true, int page = 1, int pageSize = 5)
 {
     return(messagesRepository.GetMessages(false).Include(m => m.Relays)
            .OrderBy(sortColumn + (sortIsDescending ? " DESC" : ""))
            .Select(m => new MessageSummary(m))
            .GetPaged(page, pageSize));
 }
Exemple #3
0
        public async Task <IActionResult> Get(Guid roomID)
        {
            if (roomID == Guid.Empty)
            {
                return(NotFound());
            }

            var messagesForRoom = await _messageRepository.GetMessages(roomID);

            return(messagesForRoom.Count > 0 ? (IActionResult)Ok(messagesForRoom) : NotFound());
        }
Exemple #4
0
        public MessageListResponse GetMessageList(PagingParameters pagingParameters)
        {
            int rowsCount = 0;
            MessageListResponse result = new MessageListResponse
            {
                MessageList = _messagesRepository.GetMessages(pagingParameters, out rowsCount),
                RowsCount   = rowsCount
            };

            return(result);
        }
 public IActionResult Get(string recipient)
 {
     try
     {
         var messages = _repository.GetMessages(recipient);
         return(Ok(messages));
     }
     catch (Exception ex)
     {
         _logger.LogError($"Exception in MessagesController.Get(). recipient: [{recipient}]", ex);
         return(StatusCode(500));
     }
 }
Exemple #6
0
        public MessagesControllerTests()
        {
            messagesRepository = Substitute.For <IMessagesRepository>();
            server             = Substitute.For <ISmtp4devServer>();
            controller         = new MessagesController(messagesRepository, server);
            var sqlLiteForTesting = new SqliteInMemory();

            context = new Smtp4devDbContext(sqlLiteForTesting.ContextOptions);
            InitRepo();
            messagesRepository.GetMessages(Arg.Any <bool>())
            .Returns(context.Messages);
            messagesRepository.DbContext.Returns(context);
        }
Exemple #7
0
            private void Session_GetMessagesInfo(object sender, IMAP_e_MessagesInfo e)
            {
                if (e.Folder == "INBOX")
                {
                    foreach (var message in messagesRepository.GetMessages())
                    {
                        List <string> flags = new List <string>();
                        if (!message.IsUnread)
                        {
                            flags.Add("Seen");
                        }

                        e.MessagesInfo.Add(new IMAP_MessageInfo(message.Id.ToString(), message.ImapUid, flags.ToArray(), message.Data.Length, message.ReceivedDate));
                    }
                }
            }
        public IActionResult Get()
        {
            var messages = _messagesRepository.GetMessages();

            return(Ok(messages));
        }
Exemple #9
0
 public IEnumerable <ApiModel.MessageSummary> GetSummaries(string sortColumn = "receivedDate", bool sortIsDescending = true)
 {
     return(messagesRepository.GetMessages()
            .OrderBy(sortColumn + (sortIsDescending ? " DESC" : ""))
            .Select(m => new ApiModel.MessageSummary(m)));
 }
Exemple #10
0
 public IEnumerable <Message> GetInTime(DateTime from, DateTime to)
 {
     return(_messagesRepository.GetMessages(from, to));
 }
Exemple #11
0
 /// <summary>
 /// Get api/messages получение всех сообщений
 /// </summary>
 /// <returns>Коллекция сообщений</returns>
 public IHttpActionResult Get()
 {
     return(Ok(_messagesRepository.GetMessages()));
 }
Exemple #12
0
 public IEnumerable <MessageSummary> GetSummaries(string sortColumn = "receivedDate", bool sortIsDescending = true)
 {
     return(messagesRepository.GetMessages(false).Include(m => m.Relays)
            .OrderBy(sortColumn + (sortIsDescending ? " DESC" : ""))
            .Select(m => new MessageSummary(m)));
 }