public IActionResult UpdateChatConnection(ChatConnectionsDTO connectionData) { if (!ModelState.IsValid) { return(BadRequest()); } try { var existingEntity = _context.ChatConnections.Include(c => c.RoomNameNavigation).SingleOrDefault(p => p.ConnectionId == connectionData.ConnectionId); if (existingEntity == null) { return(NotFound()); } var newEntity = _mapper.Map <ChatConnections>(connectionData); _mapper.Map(newEntity, existingEntity); _context.SaveChanges(); return(Ok(existingEntity.ConnectionId)); } catch (Exception) { return(BadRequest()); } }
public async Task <string> CreateChatConnectionAsync(ChatConnectionsDTO connectionData) { var response = await _client.PostAsJsonAsync(nameof(ChatConnectionsController.CreateChatConnection), connectionData); if (response.IsSuccessStatusCode) { var message = await response.Content.ReadAsStringAsync(); return(message); } return(null); }
public IActionResult CreateChatConnection(ChatConnectionsDTO connectionData) { if (!ModelState.IsValid) { return(BadRequest()); } try { var entity = _mapper.Map <ChatConnections>(connectionData); _context.ChatConnections.Add(entity); _context.SaveChanges(); return(Ok(entity.ConnectionId)); } catch (Exception) { return(BadRequest()); } }
public async Task UpdateChatConnectionAsync(ChatConnectionsDTO connectionData) { var a = await _client.PutAsJsonAsync(nameof(ChatConnectionsController.UpdateChatConnection), connectionData); }