Exemple #1
0
        public async Task <IEnumerable <InboxMessageDto> > GetInboxMessages(int teamId)
        {
            List <InboxMessageDto> messages = new List <InboxMessageDto>();

            var inboxMessages = await _context.InboxMessages.Where(x => x.ReceiverId == teamId).ToListAsync();

            foreach (var im in inboxMessages)
            {
                InboxMessageDto dto = new InboxMessageDto
                {
                    Id           = im.Id,
                    SenderId     = im.SenderId,
                    SenderName   = im.SenderName,
                    SenderTeam   = im.SenderTeam,
                    ReceiverId   = im.ReceiverId,
                    ReceiverName = im.ReceiverName,
                    ReceiverTeam = im.ReceiverTeam,
                    Subject      = im.Subject,
                    Body         = im.Body,
                    MessageDate  = im.MessageDate,
                    IsNew        = im.IsNew
                };
                messages.Add(dto);
            }
            return(messages);
        }
Exemple #2
0
        public async Task <bool> SendInboxMessage(InboxMessageDto message)
        {
            InboxMessage im = new InboxMessage
            {
                SenderId     = message.SenderId,
                SenderName   = message.SenderName,
                SenderTeam   = message.SenderTeam,
                ReceiverId   = message.ReceiverId,
                ReceiverName = message.ReceiverName,
                ReceiverTeam = message.ReceiverTeam,
                Subject      = message.Subject,
                Body         = message.Body,
                MessageDate  = message.MessageDate,
                IsNew        = message.IsNew
            };
            await _context.AddAsync(im);

            return(await _context.SaveChangesAsync() > 1);
        }
Exemple #3
0
        public async Task <IActionResult> SendInboxMessage(InboxMessageDto message)
        {
            var result = await _repo.SendInboxMessage(message);

            return(Ok(result));
        }