Example #1
0
        private async Task UploadContinue(string fileName, Stream stream)
        {
            Exception error = null;

            try
            {
                if (stream == null)
                {
                    await DialogService.ShowMessage("Nothing was picked", "No image");

                    IsBusy = false;
                    return;
                }

                Status = $"Uploading {fileName}";

                var info = await _service.SaveFile(Model.Id, fileName, stream);

                Status = "Refreshing children";
                await _service.Refresh(Model);

                await _service.PopulateChildren(Model);

                PopulateChildrenCollection();

                await DialogService.ShowMessage($"Uploaded file with ID {info.Id}", "Success");

                Status = "Done";
            }
            catch (Exception ex)
            {
                error = ex;
            }

            if (error != null)
            {
                await DialogService.ShowError(error, "Problem when uploading", "OK", null);

                IsBusy = false;
                Status = string.Empty;
                return;
            }

            IsBusy = false;
        }