private async Task <bool> AddWelcomeChats(string userId) { string admin = "5e4c448cbef07dff96f71f3c"; // Developer Test Account if (userId == admin) { return(false); } List <string> users = new List <string>(); users.Add(admin); users.Add(userId); var result = await _chatService.CreateGroup(null, users); if (!result.Success) { return(false); } var group = (GroupView)result.Data; foreach (string chat in chats) { await _chatService.AddChat(admin, 0, chat, group.Id, userId); } return(true); }
public async Task SendMessage(MessageRequest request) { try { var result = await _chatService.AddChat( Context.UserIdentifier, request.Type, request.Content, request.Group, request.Receiver); if (!result.Success) { await SendResponseToCaller(new ChatResponse { Type = ChatResponseType.SystemErrorMessage, Data = result.Message }); } else { await SendResponseToGroup(request.Group, new ChatResponse { Type = ChatResponseType.AddChat, Data = result.Data }); } } catch (Exception) { } }
public async Task <IActionResult> Get(string userId) { var myId = User.Claims.First(c => c.Type == "UserID").Value; if (await chatService.ExistChat(myId, userId) == false) { chatService.AddChat(userId, myId); } var dialog = await chatService.GetDialog(myId, userId); var result = dialog.Messages; if (result == null) { return(Ok("No messages yet")); } return(Ok(result)); }
public async Task <IActionResult> AddChat([FromBody] AddChatViewModel addChat) { if (ModelState.IsValid) { var chatDto = _mapper.Map <AddChatDto>(addChat); await _chatService.AddChat(chatDto); return(Ok()); } return(BadRequest()); }
public void AddChat(Chat chat) { _client.AddChat(chat); }
public async Task <bool> AddChat(ChatMessageModel model) { return(await _chatService.AddChat(model.Message, model.Username)); }