Esempio n. 1
0
        protected async Task InsertCarAsync()
        {
            IsBusy = true;
            var file = (await FileReaderService.CreateReference(inputReference).EnumerateFilesAsync()).FirstOrDefault();

            _fileInfo = await file.ReadFileInfoAsync();

            using (var ms = await file.CreateMemoryStreamAsync())
            {
                var result = await CarsService.AddCarAsync(Model, new AppFile
                {
                    FileStream = ms,
                    FileName   = $"{_fileInfo.Name}",
                    Name       = Model.CarModel
                });

                if (result.IsSuccess)
                {
                    Message    = "Car has been inserted successfully!";
                    AlertClass = "alert-success";
                    MyCars.Add(result.Value);
                }
                else
                {
                    Message    = "There is something wrong try again later";
                    AlertClass = "alert-error";
                }
            }

            IsBusy = false;
        }