public async Task LoadSupportTickets(BranchTicketsQueryContext filter, SortColumnItem sortOrder) { IsBusy = true; ICollection <TruDeskItem> list; if (IsFilterDifferentFromLast(filter)) { _previousFilter = filter; list = await Api.GetBranchTickets(filter); if (list == null) { List.Clear(); await Alert.ShowMessage("No support ticket found"); return; } } else { list = _list; } List = new ObservableCollection <TruDeskItem>(SortList(sortOrder, list)); }
public async Task <ICollection <TruDeskItem> > GetBranchTickets(BranchTicketsQueryContext filter) { filter.CustomerInfo = GetCustomerContext(); var response = await AXClient.Instance.GetBranchTicketsAsync(filter) .ConfigureAwait(false); return(response.Data); }
public async Task Load(BranchTicketsQueryContext filter = null) { try { IsBusy = true; var plantsResult = await Api.GetTicketBranches(); if (!plantsResult.Successful.GetValueOrDefault()) { await Alert.DisplayApiCallError(plantsResult.ExceptionMessage, plantsResult.ValidationErrors, nameof(AppResources.ServerError).Translate()); return; } var extendedBranches = new List <ExtendedCustomerBranchView>(); foreach (var customerBranchView in plantsResult.Data.Select(p => p.CloneToType <ExtendedCustomerBranchView, CustomerBranchView>())) { foreach (var businessUnit in customerBranchView.BuisnessUnits) { var newBranch = customerBranchView.CloneJson(); newBranch.BusinessUnit = businessUnit; extendedBranches.Add(newBranch); } } BranchList = new ObservableCollection <ExtendedCustomerBranchView>(extendedBranches); filter = filter ?? new BranchTicketsQueryContext { CustomerInfo = Api.GetCustomerContext(), CustomerBranchId = _branchList.FirstOrDefault()?.CustomerBranchId, ViewName = "All Requests", BusinessUnit = _branchList.FirstOrDefault()?.BusinessUnit.BusinessUnit, }; await LoadSupportTickets(filter, new SortColumnItem(SupportTicketsSortableColumns.LastUpdated, "Last Updated"){ Ascending = true }); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
private bool IsFilterDifferentFromLast(BranchTicketsQueryContext currentFilter) { if (_previousFilter == null) { return(true); } if (_previousFilter.BusinessUnit != currentFilter.BusinessUnit) { return(true); } if (_previousFilter.ViewName != currentFilter.ViewName) { return(true); } if (_previousFilter.CustomerBranchId != currentFilter.CustomerBranchId) { return(true); } return(false); }