in Kiosk/Views/InsuranceClaimAutomation/InsuranceClaimAutomation.xaml.cs [336:421]
private async void OnSubmitClaimButtonClicked(object sender, RoutedEventArgs e)
{
try
{
this.progressRing.IsActive = true;
CloseDetailsView();
if (CurrentInputProductImage != null && (CurrentInputFormImage != null || CurrentInputFormFile != null))
{
var claim = new DataGridViewModel(Guid.NewGuid())
{
ClaimId = ++claimId,
IsFormImage = IsFormImageSource,
CustomName = emptyRow,
Date = emptyRow,
WarrantyId = emptyRow,
Warranty = emptyRow,
InvoiceTotal = emptyRow
};
// store image file to local folder
if (CurrentInputProductImage.ImageUrl != null)
{
claim.ProductImageUri = CurrentInputProductImage.ImageUrl;
claim.ProductImage = new BitmapImage(new Uri(CurrentInputProductImage.ImageUrl));
}
else if (CurrentInputProductImage.GetImageStreamCallback != null)
{
StorageFile imageFile = await InsuranceClaimDataLoader.CreateFileInLocalFolderAsync(claim.Id, "ProductImage.jpg");
await Util.SaveBitmapToStorageFileAsync(await CurrentInputProductImage.GetImageStreamCallback(), imageFile);
claim.ProductImageUri = imageFile.Path;
claim.ProductImage = new BitmapImage(new Uri(imageFile.Path));
}
// store form file to local folder
if (isFormImageSource)
{
CurrentInputFormFile = await InsuranceClaimDataLoader.CreateFileInLocalFolderAsync(claim.Id, "FormImage.jpg");
if (CurrentInputFormImage?.ImageUrl != null)
{
claim.FormImageUri = CurrentInputFormImage.ImageUrl;
claim.FormImage = new BitmapImage(new Uri(CurrentInputFormImage.ImageUrl));
await Util.DownloadAndSaveBitmapAsync(CurrentInputFormImage.ImageUrl, CurrentInputFormFile);
}
else if (CurrentInputFormImage?.GetImageStreamCallback != null)
{
await Util.SaveBitmapToStorageFileAsync(await CurrentInputFormImage.GetImageStreamCallback(), CurrentInputFormFile);
claim.FormImageUri = CurrentInputFormFile.Path;
claim.FormImage = new BitmapImage(new Uri(CurrentInputFormFile.Path));
}
}
else if (CurrentInputFormFile != null)
{
StorageFile file = await InsuranceClaimDataLoader.CopyFileToLocalFolderAsync(CurrentInputFormFile, $"FormFile{CurrentInputFormFile.FileType}", claim.Id);
claim.FormFile = new Uri(file.Path);
}
DataGridCollection.Add(claim);
// show submitted form
this.inputSubmittedGrid.Visibility = Visibility.Visible;
// validate product image and form
await ProcessClaimAsync(claim);
// store current claim
await InsuranceClaimDataLoader.SaveOrUpdateDataAsync(claim);
// update datagrid collection
await LoadDataGridCollectionAsync();
}
}
catch (Exception ex)
{
await Util.GenericApiCallExceptionHandler(ex, "Failure processing claim");
}
finally
{
this.progressRing.IsActive = false;
}
}