예제 #1
0
        public async Task AddMessage(HttpRequest Request, HttpResponse Response, string message, int IDChatRoom)
        {
            var cookie = _userService.ReadUserCookie(Request);
            var result = await _chatRepo.AddMessage(message, cookie.id, IDChatRoom, cookie.token);

            if (!(result.IsSuccessStatusCode))
            {
                await _userService.RefreshToken(Response, cookie);

                cookie = _userService.ReadUserCookie(Request);
                result = await _chatRepo.AddMessage(message, cookie.id, IDChatRoom, cookie.token);
            }
        }
예제 #2
0
        public async Task <Message> AddMessage(User user, Dialog dialog, string content)
        {
            var message = new Message
            {
                Content = content,
                When    = DateTimeOffset.Now,
                User    = user,
                Dialog  = dialog,
                IsRead  = false
            };

            dialog.LastMessage  = content;
            dialog.LastActivity = DateTimeOffset.Now;

            await _chatRepo.AddMessage(message);

            return(message);
        }