public async Task <byte[]> ExecuteAsync(int exportType = 0, string listCustomerId = "", string search = "") { try { byte[] result; int[] listCustomerIds; List <ListCustomerViewModel> listCustomerQuery = new List <ListCustomerViewModel>(); switch (exportType) { case (int)ExportType.SelectedItems: listCustomerIds = listCustomerId != null?listCustomerId.Split(',').Select(int.Parse).ToArray() : new int[0]; listCustomerQuery = await GetSelectedCustomer(listCustomerIds); break; case (int)ExportType.SearchResult: string[] searchCondition = search != null?search.Split(';') : new string[0]; int sortField = int.Parse(searchCondition[0]); int sortType = int.Parse(searchCondition[1]); int?status = searchCondition[2].TryConvertToInt(); var data = await _getListCustomerQuery.ExecuteAsync(0, 0, sortField, sortType, status, searchCondition[3]); listCustomerQuery = data.Items.ToList(); break; } result = ExportCustomerList(listCustomerQuery); return(result); } catch (Exception) { //Logging<ExportListCustomerQuery>.Error(ex, "Data: " + JsonConvert.SerializeObject(customerIds + exportType + search)); return(new byte[0]); } }
public async Task <IActionResult> GetListCustomerAsync(int page, int pageSize, int sortField, int sortType, int?customerStatus, string searchString) { var result = await _getListCustomerQuery.ExecuteAsync(page, pageSize, sortField, sortType, customerStatus, searchString); return(new ObjectResult(result)); }