示例#1
0
        public async Task InsertBrandAsync()
        {
            IsBusy = true;

            var file = (await FileReaderService.CreateReference(inputReference).EnumerateFilesAsync()).FirstOrDefault();

            _fileInfo = await file.ReadFileInfoAsync();

            using (var ms = await file.CreateMemoryStreamAsync((int)_fileInfo.Size))
            {
                FileStream = ms;

                var result = await BrandsService.AddNewBrandAsync(Model, new AppFile
                {
                    FileStream = FileStream,
                    FileName   = _fileInfo.Name,
                    Name       = $"{Model.Name}{Path.GetExtension(_fileInfo.Name)}"
                });

                if (result.IsSuccess)
                {
                    AlertClass = "alert-success";
                    Message    = "Brand has been added successfully!";
                    brands.Add(result.Value);
                }
                else
                {
                    AlertClass = "alert-danger";
                    Message    = "There is something wrong";
                    Debug.WriteLine(result.Message);
                }
            }

            IsBusy = false;
        }