public async Task <GroupConversation> CreateGroupConversation(GroupConversationDTO groupConversationDTO) { var groupConversation = new GroupConversation() { Name = groupConversationDTO.GroupName, ConversationType = groupConversationDTO.ConversationType }; await Context.GroupConversation .AddAsync(groupConversation); await Context.SaveChangesAsync(); groupConversation = await Context.GroupConversation .FirstOrDefaultAsync(gc => gc.Name == groupConversationDTO.GroupName); foreach (var groupMember in groupConversationDTO.GroupMembers) { var groupUser = new GroupUser() { GroupId = groupConversation.Id, UserId = groupMember.Id }; await Context.GroupUser .AddAsync(groupUser); } await Context.SaveChangesAsync(); return(groupConversation); }
public async Task <ConversationDTO> CreateGroupConversationDTO(GroupConversationDTO conversationDTO) { var groupConversation = await _conversationRepository.CreateGroupConversation(conversationDTO); var groupConversationDTO = _conversationParser.ParseConversation(groupConversation); return(groupConversationDTO); }
public async Task CreateGroup() { var conversationDTO = new GroupConversationDTO() { GroupName = GroupName, ConversationType = ConversationType.Group, GroupMembers = new List <BookUser>(GroupMembers) }; var createdConversationDTO = await _conversationService.CreateGroupConversation(conversationDTO); DataContainer.ConversationDTO = createdConversationDTO; }
public async Task <ConversationDTO> CreateGroupConversation(GroupConversationDTO conversationDTO) { using (var httpClient = new HttpClient()) { var response = await httpClient.PostAsync($"{_apiURL}/Group", new StringContent( JsonConvert.SerializeObject(conversationDTO), Encoding.UTF8, "application/json" )); var jsonResponse = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ConversationDTO>(jsonResponse)); } }
public async Task <ActionResult <ConversationDTO> > CreateGroupConversation(GroupConversationDTO conversationDTO) { var conversation = await _conversationService.CreateGroupConversationDTO(conversationDTO); return(Ok(conversation)); }