public ChatMessage AddChatMessage(ChatMessage chatMessage) { using (var svc = new ServiceProxyHelper<IChatMessagesService>("ChatMessagesService")) { return svc.Proxy.AddChatMessage(chatMessage); } }
public ChatMessage AddChatMessage(ChatMessage chatMessage, string authenticationToken) { using (var svc = new HttpClientHelper()) { var result = JsonHelper.DeserializeJson<ChatMessage>( svc.Post(Constants.BlogRestUrl, "album", chatMessage, authenticationToken)); return result; } }
public ChatMessage AddChatMessage(ChatMessage chatMessage) { var result = _chatMessagesLogic.Add(chatMessage); if (result != null && result.Error != null) throw new Exception(result.Error.Message); if (result == null) return null; var sendChatMessage = new SendChatMessage { ChatMessage = result, RecipientUserId = result.ToUser.Id, ClientFunction = Constants.SocketClientFunctions.SendChatMessage.ToString() }; _redisService.Publish(sendChatMessage); return result; }
public ChatMessage Add(ChatMessage chatMessage) { try { var dbChatMessage = ChatMessageMapper.ToEntity(chatMessage); dbChatMessage.FromUser = null; dbChatMessage.ToUser = null; dbChatMessage.CreatedBy = dbChatMessage.FromUserId; dbChatMessage.ModifiedBy = dbChatMessage.FromUserId; var addResult = _chatMessageRepository.Add(dbChatMessage); var newChatMessage = _chatMessageRepository.Find(a => a.ChatMessageId == addResult.ChatMessageId, null, "FromUser,ToUser").FirstOrDefault(); if (newChatMessage == null || newChatMessage.FromUser == null || newChatMessage.ToUser == null) { throw new Exception("Successfully created message but failed to get users related to the message."); } return ChatMessageMapper.ToDto(newChatMessage); } catch (Exception ex) { throw new BlogException(ex.Message, ex.InnerException); } }