public IHttpActionResult ExportList(int listId) { var list = sqlDataAccess.GetList(ControllerHelper.GetCurrentUserId(), listId); list.Items = GetFavoritesContainedOnList(listId); var language = GetUserAccess(WebHelper.GetClientLanguage(Request)).Language; return(ResponseMessage(veExportRecordHelper.CreateExcelFile(ConvertExportData(list.Items.Where(i => i is VeFavorite).ToList()), language, FrontendSettingsViaduc.Instance.GetTranslation(language, "accountFavoritesDetailPageComponent.fileName") + $"{list.Name}.xlsx", FrontendSettingsViaduc.Instance.GetTranslation("en", "accountFavoritesDetailPageComponent.fileName") + $"{DateTime.Now.ToString("yyyy-MM-dd-hh_mm_ss")}.xlsx"))); }
public IHttpActionResult ExportSearchResultToExcel(string searchText) { ISearchResult searchResult; var search = JsonConvert.DeserializeObject <SearchParameters>(searchText); try { string language = WebHelper.GetClientLanguage(Request); var error = entityProvider.CheckSearchParameters(search, language); if (!string.IsNullOrEmpty(error)) { return(new BadRequestErrorMessageResult(error, this)); } var access = GetUserAccess(language); search.Paging.Skip = 0; search.Paging.Take = 10000; searchResult = entityProvider.Search <SearchRecord>(search, access); if (searchResult is SearchResult <SearchRecord> searchRecords) { return(ResponseMessage(veExportRecordHelper.CreateExcelFile( ConvertExportData(searchRecords.Entities.Items.Select(i => i.Data).ToList()), language, FrontendSettingsViaduc.Instance.GetTranslation(language, "veExportRecord.fileName") + $"-{DateTime.Now.ToString("yyyy-MM-dd-hh_mm_ss")}.xlsx", FrontendSettingsViaduc.Instance.GetTranslation("en", "veExportRecord.fileName") + $"-{DateTime.Now.ToString("yyyy-MM-dd-hh_mm_ss")}.xlsx"))); } } catch (Exception ex) { Log.Error(ex, "Search for {searchQuery} failed", JsonConvert.SerializeObject(search, Formatting.Indented)); return(InternalServerError(ex)); } return(StatusCode(HttpStatusCode.NoContent)); }