/// <returns>A task that represents the asynchronous operation</returns> public virtual async Task <IActionResult> ExportCsv() { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCountries)) { return(AccessDeniedView()); } var fileName = $"states_{DateTime.Now:yyyy-MM-dd-HH-mm-ss}_{CommonHelper.GenerateRandomDigitCode(4)}.csv"; var states = await _stateProvinceService.GetStateProvincesAsync(true); var result = await _exportManager.ExportStatesToTxtAsync(states); return(File(Encoding.UTF8.GetBytes(result), MimeTypes.TextCsv, fileName)); }