public async Task <OutgoingFile> SaveAsync(string fileName, byte[] fileContents)
        {
            try
            {
                var filePath = await _fileStorage.SaveAsync(fileName, fileContents);

                var incomingFile = new IncomingFile
                {
                    AddedOn  = DateTime.UtcNow,
                    FileName = fileName,
                    Path     = filePath,
                    Size     = fileContents.Length
                };

                var incomingFileEntity = _mapper.Map <File>(incomingFile);

                var outgoingFileEntity = await _repository.AddAsync(incomingFileEntity);

                var outgoingFile = _mapper.Map <OutgoingFile>(outgoingFileEntity);

                return(outgoingFile);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Unable to save {fileName}: {e.Message}");
                throw;
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            var application = new App();

            string action = Intent.Action;
            string type   = Intent.Type;

            if (action.Equals(action) && !String.IsNullOrEmpty(type))
            {
                Android.Net.Uri fileUri = Intent.Data;

                string fileContent = File.ReadAllText(fileUri.Path);
                string fileName    = fileUri.LastPathSegment;

                var incomingFile = new IncomingFile {
                    Name = fileName, Content = fileContent, Path = fileUri.Path, Type = "", DateCreated = new DateTime()
                };
                application.IncomingFile = incomingFile;
            }

            LoadApplication(application);
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            StorageFile storageFile = e.Parameter as StorageFile;

            if (storageFile != null)
            {
                string content;
                try
                {
                    content = await FileIO.ReadTextAsync(storageFile, UnicodeEncoding.Utf8);
                }
                catch
                {
                    content = await FileIO.ReadTextAsync(storageFile, UnicodeEncoding.Utf16BE);
                }

                var incomingFile = new IncomingFile
                {
                    Path        = storageFile.Path,
                    Name        = storageFile.Name,
                    DateCreated = storageFile.DateCreated.DateTime,
                    Type        = storageFile.DisplayType,
                    Content     = content
                };
                _app.IncomingFile = incomingFile;
            }
            base.OnNavigatedTo(e);
        }