private async void SaveCommandExecute() { this.IsBusy = true; this.Message = string.Empty; Location location = this.Location; PostPostData data = new PostPostData() { Content = Text, Latitude = location.Latitude, Longitude = location.Longitude }; try { await App.Client.PostPostAsync(data); await Shell.Current.GoToAsync(".."); } catch (ApiException exception) { this.Message = exception.ToString(); } finally { this.IsBusy = true; } }
private async void SaveCommandExecute(object o) { this.IsBusy = true; this.Message = string.Empty; try { var location = await this.locationCache.GetCurrentLocation(Enums.TimePassed.JustNow); PostPostData data = new PostPostData() { Content = Text, Latitude = location.Latitude, Longitude = location.Longitude }; var postData = await App.Client.PostPostAsync(data); if (o is Stream stream) { FileParameter file = new FileParameter(stream, System.IO.Path.GetFileName(this.fileName)); await App.Client.PostImageAsync(postData.Id, file); } await Shell.Current.GoToAsync(".."); } catch (Exception exception) { this.Message = exception.ToString(); } finally { this.IsBusy = false; } }
public async Task <PostPostResultData> Post([FromBody] PostPostData daten) { using SqlConnection connection = this.userService.Connection; UserEntity user = await this.userDatabaseAccess.Get(this.userService.Username, connection); DateTime now = DateTime.Now; PostEntity newPost = new PostEntity(); newPost.CopyPropertiesFrom(daten); newPost.Creationdate = now; newPost.AuthorId = user.Id; using DatabaseContext context = new DatabaseContext(connection); await using var transaction = await context.Database.BeginTransactionAsync(); await context.Post.AddAsync(newPost); await context.SaveChangesAsync(); await CheckGroups(daten.Content, user.Id, newPost.Id, now, context); await transaction.CommitAsync(); connection.Close(); return(new PostPostResultData() { Id = newPost.Id }); }