public async static Task ExportToHtml(HelpRequestModel request, StorageFile file) { StringBuilder sb = new StringBuilder(); sb.Append("<!DOCTYPE html>\n"); sb.Append("<html>\n"); sb.Append("<head>\n<title>" + request.Title + "</title>\n</head>\n"); sb.Append("<body>\n"); sb.Append("<h1>" + request.Title + "</h1>\n"); sb.Append("<img src=\"" + request.PictureUrl + "\" />\n"); sb.Append("<p>" + request.Text + "</p>\n"); sb.Append("</body>\n</html>"); await FileIO.WriteTextAsync(file, sb.ToString()); }
public static async Task EditRequest(HelpRequestModel request, string sessionKey) { headers[sessionHeaderName] = sessionKey; await HttpRequester.Post(baseUrl + "edit", request, headers); }
private async void HandleAddRequest(object obj) { try { if(string.IsNullOrEmpty(Title) || string.IsNullOrWhiteSpace(Title)) { ErrorMessage = "Enter a request title"; return; } if (string.IsNullOrEmpty(Text) || string.IsNullOrWhiteSpace(Text)) { ErrorMessage = "Enter a request text"; return; } var geolocator = new Geolocator(); geolocator.DesiredAccuracy = PositionAccuracy.High; var position = await geolocator.GetGeopositionAsync(); var coordinates = new CoordinatesModel() { Latitude = position.Coordinate.Latitude, Longitude = position.Coordinate.Longitude }; var request = new HelpRequestModel() { Title = Title, Text = Text, PictureUrl = PictureUrl, Coordinates = coordinates }; IsAddingRequest = true; OnPropertyChanged("IsAddingRequest"); await HelpRequestsPersister.AddRequest(request, AccountManager.CurrentUser.SessionKey); NavigationService.Navigate(ViewType.MyRequests); NotificationsManager.ShowToastNotification("Request added"); } catch (Exception ex) { ErrorMessage = "Unable to get location"; IsAddingRequest = false; OnPropertyChanged("IsAddingRequest"); } }