public async Task SendMessageAsync( Posts posts) { var httpClient = new HttpClient(); httpClient.BaseAddress = new Uri("http://localhost:1874/", UriKind.RelativeOrAbsolute); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var jsonData = new Posts { Text = posts.Text, UserId = posts.UserId, Privacy = posts.Privacy, CommentList = posts.CommentList }; var response = await httpClient.PostAsJsonAsync(new Uri(BaseUrl1), jsonData); if (response.IsSuccessStatusCode) { SubmitSucced= true; } }
public HomeViewModel(INavigationService navigationService, ILogManager logManager, ISessionService sessionService, IMessageBoxService messageBox) { _posts = new Posts(); _navigationService = navigationService; _logManager = logManager; _sessionService = sessionService; HomeCommand = new RelayCommand(HomeHub); LogoutCommand = new RelayCommand(LogOut); SendCommand = new RelayCommand(SendMsg); dataServicesChat = new DataServiceChat(); _messageBox = messageBox; }