public async void CreateNewMessage(Team team) { var newMsg = new Message(Message,FrontPage); var dbcontext = new WSContext(); await dbcontext.CreateMessage(newMsg); await dbcontext.LoadMessages(); team.Message = SCommon.MessageList.Last().Id; dbcontext.UpdateTeam(team); frame.Navigate(typeof (MainPage)); }
public void SetFrontpageMessage() { if (MessageList != null) { var newestMessage = new Message(null, false); foreach (var message in MessageList) { if (message.Id > newestMessage.Id && message.Frontpage) { newestMessage = message; } } FrontpageMessage = newestMessage.ToString(); } }
public async Task CreateMessage(Message message) { handler = new HttpClientHandler(); handler.UseDefaultCredentials = true; using (var client = new HttpClient(handler)) { client.BaseAddress = new Uri(ServerUrl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var response = await client.PostAsJsonAsync("Messages", message, CancelToken.Token); } catch (Exception ex) { new MessageDialog(ex.Message).ShowAsync(); } } }