private void OnFilterTriggered(SortColumnItem sortColumn) { if (!(_barcodes?.Any() ?? false) || sortColumn?.Key == null) { return; } //IsAscending = !_isAscending; if (sortColumn.Key == "barcode") { Barcodes = _isAscending ? new ObservableCollection <ProofOfDeliveryViewModel>(_barcodes.OrderBy(p => p.Barcode)) : new ObservableCollection <ProofOfDeliveryViewModel>(_barcodes.OrderByDescending(p => p.Barcode)); } else { Barcodes = _isAscending ? new ObservableCollection <ProofOfDeliveryViewModel>(_barcodes.OrderBy(p => p.DateCreated.GetValueOrDefault())) : new ObservableCollection <ProofOfDeliveryViewModel>(_barcodes.OrderByDescending(p => p.DateCreated.GetValueOrDefault())); } }
private async Task OnFilterTrigger(SortColumnItem arg) { if (arg == null) { return; } try { IsBusy = true; ShowFilter = false; _currentFilter = arg; CustomerList?.Clear(); await Refresh(_countContext); } finally { IsBusy = false; } }
private static IEnumerable <InvoicePaymentView> SortList(SortColumnItem sortOrder, IEnumerable <InvoicePaymentView> list) { switch (sortOrder.Key.ObjectToEnum <SettlementsSortColumns>()) { case SettlementsSortColumns.AccountNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.AXCustomerId).ToList() : list.OrderByDescending(p => p.AXCustomerId).ToList(); break; case SettlementsSortColumns.Account: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerName).ToList() : list.OrderByDescending(p => p.CustomerName).ToList(); break; case SettlementsSortColumns.PaidBy: list = sortOrder.Ascending ? list.OrderBy(p => p.PaidBy).ToList() : list.OrderByDescending(p => p.PaidBy).ToList(); break; case SettlementsSortColumns.Date: list = sortOrder.Ascending ? list.OrderBy(p => p.DateProcessed.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.DateProcessed.GetValueOrDefault()).ToList(); break; case SettlementsSortColumns.MoneyOnAccount: list = sortOrder.Ascending ? list.OrderBy(p => p.IsMoneyOnAccountRequest.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.IsMoneyOnAccountRequest.GetValueOrDefault()).ToList(); break; case SettlementsSortColumns.Note: list = sortOrder.Ascending ? list.OrderBy(p => p.Note).ToList() : list.OrderByDescending(p => p.Note).ToList(); break; default: throw new ArgumentOutOfRangeException(); } return(list); }
private async Task OnFilterChanged(SortColumnItem arg) { try { if (_previousFilter == null) { return; } IsBusy = true; ShowFilter = false; await Refresh(_previousFilter, arg); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
private async Task OnFilterChanged(SortColumnItem arg) { try { if (arg == null) { return; } IsBusy = true; var sortedList = SortList(arg, _list); List = new ObservableCollection <CustomerNotification>(sortedList); _previousSortColumn = arg; } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
public async Task Load(DateTime?startTime = null, DateTime?endTime = null, SortColumnItem sortColumn = null) { try { IsBusy = true; if (sortColumn == null) { sortColumn = new SortColumnItem(NotificationSortColumns.RecordId, null); } var context = new CustomerNotificationsQueryContext { CustomerInfo = Api.GetCustomerContext(), FromDate = startTime ?? DateTime.Now.AddMonths(-3), ToDate = endTime ?? DateTimeOffset.Now }; var notificationsResponse = await Api.GetNotifications(context); if (!notificationsResponse.Successful.GetValueOrDefault()) { await Alert.ShowMessage(notificationsResponse.ExceptionMessage); return; } var sortedList = SortList(sortColumn, notificationsResponse.Data); List = new ObservableCollection <CustomerNotification>(sortedList); NoResults = !_list.Any(); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
private static List <TruDeskItem> SortList(SortColumnItem sortOrder, ICollection <TruDeskItem> list) { List <TruDeskItem> orderedList; switch ((SupportTicketsSortableColumns)Enum.ToObject(typeof(SupportTicketsSortableColumns), sortOrder.Key)) { case SupportTicketsSortableColumns.Id: { orderedList = sortOrder.Ascending ? list.OrderBy(p => p.Id).ToList() : list.OrderByDescending(p => p.Id).ToList(); } break; case SupportTicketsSortableColumns.Status: { orderedList = sortOrder.Ascending ? list.OrderBy(p => p.Status).ToList() : list.OrderByDescending(p => p.Status).ToList(); } break; case SupportTicketsSortableColumns.Subject: { orderedList = sortOrder.Ascending ? list.OrderBy(p => p.Subject).ToList() : list.OrderByDescending(p => p.Subject).ToList(); } break; case SupportTicketsSortableColumns.Contact: { orderedList = sortOrder.Ascending ? list.OrderBy(p => p.Contact).ToList() : list.OrderByDescending(p => p.Contact).ToList(); } break; case SupportTicketsSortableColumns.LastUpdated: { orderedList = sortOrder.Ascending ? list.OrderBy(p => p.UpdatedTime).ToList() : list.OrderByDescending(p => p.UpdatedTime).ToList(); } break; case SupportTicketsSortableColumns.SupportRep: { orderedList = sortOrder.Ascending ? list.OrderBy(p => p.SupportRep).ToList() : list.OrderByDescending(p => p.SupportRep).ToList(); } break; case SupportTicketsSortableColumns.Priority: { orderedList = sortOrder.Ascending ? list.OrderBy(p => p.Priority).ToList() : list.OrderByDescending(p => p.Priority).ToList(); } break; default: throw new ArgumentOutOfRangeException(); } return(orderedList); }
private static ICollection <AppUserView> SortList(SortColumnItem sortOrder, ICollection <AppUserView> list) { if (sortOrder == null) { return(list); } var sortByColumn = sortOrder.Key.ObjectToEnum <UserSortableColumns>(); switch (sortByColumn) { case UserSortableColumns.FirstName: { list = sortOrder.Ascending ? list.OrderBy(p => p.FirstName).ToList() : list.OrderByDescending(p => p.FirstName).ToList(); } break; case UserSortableColumns.LastName: { list = sortOrder.Ascending ? list.OrderBy(p => p.LastName).ToList() : list.OrderByDescending(p => p.LastName).ToList(); } break; case UserSortableColumns.Email: { list = sortOrder.Ascending ? list.OrderBy(p => p.LoginId).ToList() : list.OrderByDescending(p => p.LoginId).ToList(); } break; case UserSortableColumns.Status: { list = sortOrder.Ascending ? list.OrderBy(p => p.AccountStatus?.Name ?? string.Empty).ToList() : list.OrderByDescending(p => p.AccountStatus?.Name ?? string.Empty).ToList(); } break; case UserSortableColumns.Created: { list = sortOrder.Ascending ? list.OrderBy(p => p.DateCreated).ToList() : list.OrderByDescending(p => p.DateCreated).ToList(); } break; case UserSortableColumns.IsAdmin: { list = sortOrder.Ascending ? list.OrderBy(p => p.IsAdmin).ToList() : list.OrderByDescending(p => p.IsAdmin).ToList(); } break; case UserSortableColumns.TimeZone: { list = sortOrder.Ascending ? list.OrderBy(p => p?.TimeZone?.Name ?? string.Empty).ToList() : list.OrderByDescending(p => p?.TimeZone?.Name ?? string.Empty).ToList(); } break; case UserSortableColumns.Language: { list = sortOrder.Ascending ? list.OrderBy(p => p.Language).ToList() : list.OrderByDescending(p => p.Language).ToList(); } break; case UserSortableColumns.PhoneNumber: { list = sortOrder.Ascending ? list.OrderBy(p => p?.PhoneNumber ?? string.Empty).ToList() : list.OrderByDescending(p => p.PhoneNumber ?? string.Empty).ToList(); } break; //case UserSortableColumns.Users: //{ // list = sortOrder.Ascending ? list.OrderBy(p => p?.AppUserId ?? string.Empty).ToList() // : list.OrderByDescending(p => p.PhoneNumber ?? string.Empty).ToList(); // } // break; default: throw new ArgumentOutOfRangeException(); } return(list); }
public async Task Load(OrderFilter filter = null, SortColumnItem sortColumnItem = null) { try { IsBusy = true; if (filter == null) { filter = new OrderFilter { AccountNumber = Settings.AxCustomerId, SelectedStatus = new KeyValuePair <SalesOrderQueryContextStatus, string>(SalesOrderQueryContextStatus.BackOrder, nameof(AppResources.OpenOrder).Translate()) }; } if (Math.Abs((filter.EndDate.GetValueOrDefault() - filter.StartDate.GetValueOrDefault()).TotalDays) > 90) { await Alert.ShowMessage(nameof(AppResources.DiffLessThan90DaysMessage).Translate()); return; } if (sortColumnItem != null) { _sortColumnItem = sortColumnItem; } else if (_sortColumnItem == null) { _sortColumnItem = new SortColumnItem(OrdersSortableColumns.OrderNumber, null) { Ascending = true }; } if (IsFilterDifferentFromLast(filter)) { var lines = await Api.GetOrders(filter); if (!lines.Successful.GetValueOrDefault()) { await Alert.DisplayApiCallError(lines.ExceptionMessage, lines.ValidationErrors); return; } _previousFilter = filter; _rawList = lines.Data.ToList(); } TotalAmount = (decimal)_rawList.Sum(p => p.NetAmount.GetValueOrDefault()); RowCount = _rawList.Count; var sortedLines = SortList(_sortColumnItem, _rawList) .Take(filter.SelectedQty) .ToList(); GroupedList = sortedLines.GroupBy(p => $"{p.Account.Key} - {p.Account.Name}", p => p) .ToGroupedObservable() .ToObservableCollection(); NoResults = !sortedLines.Any(); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
private static List <CustomerCreditCardTokenViewModel> SortList(SortColumnItem sortOrder, ICollection <CustomerCreditCardTokenViewModel> list) { List <CustomerCreditCardTokenViewModel> orderedList; if ((!list?.Any()) ?? true) { return(new List <CustomerCreditCardTokenViewModel>()); } switch (sortOrder.Key.ObjectToEnum <CreditCardSortColumns>()) { case CreditCardSortColumns.CardType: { orderedList = sortOrder.Ascending ? list.OrderBy(p => p.CardType).ToList() : list.OrderByDescending(p => p.CardType).ToList(); } break; case CreditCardSortColumns.CardNumber: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.FriendlyName).ToList() : list.OrderByDescending(p => p.FriendlyName).ToList(); break; case CreditCardSortColumns.ExpiryDate: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.ExpiryDate).ToList() : list.OrderByDescending(p => p.ExpiryDate).ToList(); break; case CreditCardSortColumns.AccountNumber: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.AccountNo).ToList() : list.OrderByDescending(p => p.AccountNo).ToList(); break; case CreditCardSortColumns.AccountName: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.Account).ToList() : list.OrderByDescending(p => p.Account).ToList(); break; case CreditCardSortColumns.Address: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.Address).ToList() : list.OrderByDescending(p => p.Address).ToList(); break; case CreditCardSortColumns.DateCreated: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.DateCreated.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.DateCreated.GetValueOrDefault()).ToList(); break; case CreditCardSortColumns.CreatedBy: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.CreatedBy).ToList() : list.OrderByDescending(p => p.CreatedBy).ToList(); break; case CreditCardSortColumns.DateUpdated: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.DateUpdated.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.DateUpdated.GetValueOrDefault()).ToList(); break; case CreditCardSortColumns.UpdatedBy: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.UpdatedBy).ToList() : list.OrderByDescending(p => p.UpdatedBy).ToList(); break; case CreditCardSortColumns.CopyEmailReceiptAddress: orderedList = sortOrder.Ascending ? list.OrderBy(p => p.CopyReceiptEmailAddresses?.Count ?? 0).ToList() : list.OrderByDescending(p => p.CopyReceiptEmailAddresses?.Count ?? 0).ToList(); break; default: throw new ArgumentOutOfRangeException(); } return(orderedList); }
private static ICollection <SalesQuotationInquiry> SortList(SortColumnItem sortOrder, ICollection <SalesQuotationInquiry> list) { switch (sortOrder.Key.ObjectToEnum <PipelineSortColumn>()) { case PipelineSortColumn.AccountNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.CustAccount).ToList() : list.OrderByDescending(p => p.CustAccount).ToList(); break; case PipelineSortColumn.Plant: list = sortOrder.Ascending ? list.OrderBy(p => p.InventLocationName).ToList() : list.OrderByDescending(p => p.InventLocationName).ToList(); break; case PipelineSortColumn.Quotation: list = sortOrder.Ascending ? list.OrderBy(p => p.QuotationId).ToList() : list.OrderByDescending(p => p.QuotationId).ToList(); break; case PipelineSortColumn.AccountName: list = sortOrder.Ascending ? list.OrderBy(p => p.CustName).ToList() : list.OrderByDescending(p => p.CustName).ToList(); break; case PipelineSortColumn.Status: list = sortOrder.Ascending ? list.OrderBy(p => p.Status).ToList() : list.OrderByDescending(p => p.Status).ToList(); break; case PipelineSortColumn.Amount: list = sortOrder.Ascending ? list.OrderBy(p => p.TotalInvoiceAmount.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.TotalInvoiceAmount.GetValueOrDefault()).ToList(); break; case PipelineSortColumn.CustomerRef: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerRef).ToList() : list.OrderByDescending(p => p.CustomerRef).ToList(); break; case PipelineSortColumn.Percent: list = sortOrder.Ascending ? list.OrderBy(p => p.Probability.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.Probability.GetValueOrDefault()).ToList(); break; case PipelineSortColumn.LeadTime: list = sortOrder.Ascending ? list.OrderBy(p => p.LeadTime).ToList() : list.OrderByDescending(p => p.LeadTime).ToList(); break; case PipelineSortColumn.DateCreated: list = sortOrder.Ascending ? list.OrderBy(p => p.DateCreated.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.DateCreated.GetValueOrDefault()).ToList(); break; case PipelineSortColumn.SalesResponsible: list = sortOrder.Ascending ? list.OrderBy(p => p.SalesResponsible).ToList() : list.OrderByDescending(p => p.SalesResponsible).ToList(); break; case PipelineSortColumn.ExpiryDate: list = sortOrder.Ascending ? list.OrderBy(p => p.ExpiryDate.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.ExpiryDate.GetValueOrDefault()).ToList(); break; case PipelineSortColumn.Notes: list = sortOrder.Ascending ? list.OrderBy(p => p.Note).ToList() : list.OrderByDescending(p => p.Note).ToList(); break; case PipelineSortColumn.ContactName: list = sortOrder.Ascending ? list.OrderBy(p => p.ContactName).ToList() : list.OrderByDescending(p => p.ContactName).ToList(); break; case PipelineSortColumn.FollowUpDate: list = sortOrder.Ascending ? list.OrderBy(p => p.FollowUpDate).ToList() : list.OrderByDescending(p => p.FollowUpDate).ToList(); break; default: throw new ArgumentOutOfRangeException(); } return(list); }
private static ICollection <PackingSlip> SortList(SortColumnItem sortOrder, ICollection <PackingSlip> list) { switch (sortOrder.Key.ObjectToEnum <PackingSlipSortableColumns>()) { case PackingSlipSortableColumns.AccountNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.Account.Key).ToList() : list.OrderByDescending(p => p.Account.Key).ToList(); break; case PackingSlipSortableColumns.Account: list = sortOrder.Ascending ? list.OrderBy(p => p.Account.Name).ToList() : list.OrderByDescending(p => p.Account.Name).ToList(); break; case PackingSlipSortableColumns.Plant: list = sortOrder.Ascending ? list.OrderBy(p => p.InventLocationName).ToList() : list.OrderByDescending(p => p.InventLocationName).ToList(); break; case PackingSlipSortableColumns.OrderNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.Order.Key).ToList() : list.OrderByDescending(p => p.Order.Key).ToList(); break; case PackingSlipSortableColumns.JobName: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerRef).ToList() : list.OrderByDescending(p => p.CustomerRef).ToList(); break; case PackingSlipSortableColumns.PurchaseOrder: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerPurchaseOrderNo).ToList() : list.OrderByDescending(p => p.CustomerPurchaseOrderNo).ToList(); break; case PackingSlipSortableColumns.OrderDate: list = sortOrder.Ascending ? list.OrderBy(p => p.OrderDate).ToList() : list.OrderByDescending(p => p.OrderDate).ToList(); break; case PackingSlipSortableColumns.DateShipped: list = sortOrder.Ascending ? list.OrderBy(p => p.DateShipped).ToList() : list.OrderByDescending(p => p.DateShipped).ToList(); break; case PackingSlipSortableColumns.Sqft: list = sortOrder.Ascending ? list.OrderBy(p => p.TotalSqft).ToList() : list.OrderByDescending(p => p.TotalSqft).ToList(); break; case PackingSlipSortableColumns.Lines: list = sortOrder.Ascending ? list.OrderBy(p => p.LinesCount.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.LinesCount.GetValueOrDefault()).ToList(); break; case PackingSlipSortableColumns.Safety: list = sortOrder.Ascending ? list.OrderBy(p => p.SafetyIndicator).ToList() : list.OrderByDescending(p => p.SafetyIndicator).ToList(); break; case PackingSlipSortableColumns.PackingSlip: list = sortOrder.Ascending ? list.OrderBy(p => p.Key).ToList() : list.OrderByDescending(p => p.Key).ToList(); break; case PackingSlipSortableColumns.RequestedDeliveryDate: // throw new Exception("Requested Delivery Date field is not yet available in API response data"); break; case PackingSlipSortableColumns.ClockIn: list = sortOrder.Ascending ? list.OrderBy(p => p.ClockInDateTime.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.ClockInDateTime.GetValueOrDefault()).ToList(); break; case PackingSlipSortableColumns.ClockOut: list = sortOrder.Ascending ? list.OrderBy(p => p.ClockOutDateTime.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.ClockOutDateTime.GetValueOrDefault()).ToList(); break; case PackingSlipSortableColumns.Status: list = sortOrder.Ascending ? list.OrderBy(p => p.Status).ToList() : list.OrderByDescending(p => p.Status).ToList(); break; default: throw new ArgumentOutOfRangeException(); } return(list); }
private void OnFilterTriggered(SortColumnItem sortOrder) { DateChangesList = new ObservableCollection <CfmDlvDateTracking>(SortList(sortOrder, _dateChangesList)); }
private static ICollection <InvoiceModel> SortList(SortColumnItem sortOrder, ICollection <InvoiceModel> list) { switch (sortOrder.Key.ObjectToEnum <InvoiceSortableColumns>()) { case InvoiceSortableColumns.AccountNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.Account.Key).ToList() : list.OrderByDescending(p => p.Account.Key).ToList(); break; case InvoiceSortableColumns.Account: list = sortOrder.Ascending ? list.OrderBy(p => p.Account.Name).ToList() : list.OrderByDescending(p => p.Account.Name).ToList(); break; case InvoiceSortableColumns.PurchaseOrder: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerPurchaseOrderNo).ToList() : list.OrderByDescending(p => p.CustomerPurchaseOrderNo).ToList(); break; case InvoiceSortableColumns.JobName: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerRef).ToList() : list.OrderByDescending(p => p.CustomerRef).ToList(); break; case InvoiceSortableColumns.Plant: list = sortOrder.Ascending ? list.OrderBy(p => p.InventLocationName).ToList() : list.OrderByDescending(p => p.InventLocationName).ToList(); break; case InvoiceSortableColumns.Status: list = sortOrder.Ascending ? list.OrderBy(p => p.InvoiceStatus).ToList() : list.OrderByDescending(p => p.InvoiceStatus).ToList(); break; case InvoiceSortableColumns.OrderNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.Order.Key).ToList() : list.OrderByDescending(p => p.Order.Key).ToList(); break; case InvoiceSortableColumns.Invoice: list = sortOrder.Ascending ? list.OrderBy(p => p.Key).ToList() : list.OrderByDescending(p => p.Key).ToList(); break; case InvoiceSortableColumns.InvoiceDate: list = sortOrder.Ascending ? list.OrderBy(p => p.InvoiceDate).ToList() : list.OrderByDescending(p => p.InvoiceDate).ToList(); break; case InvoiceSortableColumns.DueDate: list = sortOrder.Ascending ? list.OrderBy(p => p.DueDate).ToList() : list.OrderByDescending(p => p.DueDate).ToList(); break; case InvoiceSortableColumns.Amount: list = sortOrder.Ascending ? list.OrderBy(p => p.Amount).ToList() : list.OrderByDescending(p => p.Amount).ToList(); break; case InvoiceSortableColumns.TotalInvoiceAmount: list = sortOrder.Ascending ? list.OrderBy(p => p.TotalInvoiceAmount).ToList() : list.OrderByDescending(p => p.TotalInvoiceAmount).ToList(); break; case InvoiceSortableColumns.Terms: list = sortOrder.Ascending ? list.OrderBy(p => p.Terms).ToList() : list.OrderByDescending(p => p.Terms).ToList(); break; case InvoiceSortableColumns.SalesPerson: list = sortOrder.Ascending ? list.OrderBy(p => p.SalesPerson).ToList() : list.OrderByDescending(p => p.SalesPerson).ToList(); break; case InvoiceSortableColumns.Weight: list = sortOrder.Ascending ? list.OrderBy(p => p.TotalWeight).ToList() : list.OrderByDescending(p => p.TotalWeight).ToList(); break; case InvoiceSortableColumns.Sqft: list = sortOrder.Ascending ? list.OrderBy(p => p.TotalSqft).ToList() : list.OrderByDescending(p => p.TotalSqft).ToList(); break; default: throw new ArgumentOutOfRangeException(); } return(list); }
public async Task Load(InvoicesFilterModel filter = null, SortColumnItem sortColumnItem = null) { try { IsBusy = true; filter = filter ?? GetDefaultFilter(); if (sortColumnItem == null) { sortColumnItem = new SortColumnItem(InvoiceSortableColumns.InvoiceDate, null) { Ascending = true }; } IEnumerable <InvoiceModel> lines; if (IsFilterDifferentFromLast(filter)) { var result = await Api.GetInvoiceList(filter); if (!result.Successful.GetValueOrDefault()) { await Alert.ShowMessage(result.ExceptionMessage); return; } lines = new List <InvoiceModel>(result.Data.Select(p => p.CloneToType <InvoiceModel, Invoice>())); } else { lines = _list; } var sortedLines = SortList(sortColumnItem, lines.ToList()) .Take(filter.SelectedQty); _previousFilter = filter; if (_list != null) { foreach (var invoiceModel in _list) { invoiceModel.PropertyChanged -= InvoiceModel_PropertyChanged; } } List = new ObservableCollection <InvoiceModel>(sortedLines); if (_list != null) { foreach (var invoiceModel in _list) { invoiceModel.PropertyChanged += InvoiceModel_PropertyChanged; } } NoResults = !(_list?.Any() ?? false); //TotalAmount = (decimal)sortedLines.Sum(p => p.Amount.GetValueOrDefault()); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
private static ICollection <PackingSlipModel> SortList(SortColumnItem sortOrder, ICollection <PackingSlipModel> list) { switch ((PackingSlipSortableColumns)sortOrder.Key) { case PackingSlipSortableColumns.AccountNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.AccountNumber).ToList() : list.OrderByDescending(p => p.AccountNumber).ToList(); break; case PackingSlipSortableColumns.Account: list = sortOrder.Ascending ? list.OrderBy(p => p.Account).ToList() : list.OrderByDescending(p => p.Account).ToList(); break; case PackingSlipSortableColumns.PurchaseOrder: list = sortOrder.Ascending ? list.OrderBy(p => p.PurchaseOrder).ToList() : list.OrderByDescending(p => p.PurchaseOrder).ToList(); break; case PackingSlipSortableColumns.JobName: list = sortOrder.Ascending ? list.OrderBy(p => p.JobName).ToList() : list.OrderByDescending(p => p.JobName).ToList(); break; case PackingSlipSortableColumns.OrderNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.OrderNumber).ToList() : list.OrderByDescending(p => p.OrderNumber).ToList(); break; case PackingSlipSortableColumns.Plant: list = sortOrder.Ascending ? list.OrderBy(p => p.Plant).ToList() : list.OrderByDescending(p => p.Plant).ToList(); break; case PackingSlipSortableColumns.PackingSlip: list = sortOrder.Ascending ? list.OrderBy(p => p.Voucher).ToList() : list.OrderByDescending(p => p.Voucher).ToList(); break; case PackingSlipSortableColumns.OrderDate: list = sortOrder.Ascending ? list.OrderBy(p => p.OrderDate).ToList() : list.OrderByDescending(p => p.OrderDate).ToList(); break; case PackingSlipSortableColumns.DateShipped: list = sortOrder.Ascending ? list.OrderBy(p => p.DateShipped).ToList() : list.OrderByDescending(p => p.DateShipped).ToList(); break; case PackingSlipSortableColumns.RequestedDeliveryDate: list = sortOrder.Ascending ? list.OrderBy(p => p.RequestedDeliveryDate).ToList() : list.OrderByDescending(p => p.RequestedDeliveryDate).ToList(); break; case PackingSlipSortableColumns.Terms: list = sortOrder.Ascending ? list.OrderBy(p => p.Terms).ToList() : list.OrderByDescending(p => p.Terms).ToList(); break; case PackingSlipSortableColumns.Weight: list = sortOrder.Ascending ? list.OrderBy(p => p.Weight).ToList() : list.OrderByDescending(p => p.Weight).ToList(); break; case PackingSlipSortableColumns.Sqft: list = sortOrder.Ascending ? list.OrderBy(p => p.Sqft).ToList() : list.OrderByDescending(p => p.Sqft).ToList(); break; case PackingSlipSortableColumns.Lines: list = sortOrder.Ascending ? list.OrderBy(p => p.Lines).ToList() : list.OrderByDescending(p => p.Lines).ToList(); break; case PackingSlipSortableColumns.Voucher: list = sortOrder.Ascending ? list.OrderBy(p => p.Voucher).ToList() : list.OrderByDescending(p => p.Voucher).ToList(); break; default: throw new ArgumentOutOfRangeException(); } return(list); }
public async Task Load(ReturnOrderQueryContext filter = null, SortColumnItem sortColumnItem = null) { try { IsBusy = true; if (filter == null) { filter = new ReturnOrderQueryContext { CustomerInfo = Api.GetCustomerContext(), }; } if ((filter.EndDate.GetValueOrDefault() - filter.StartDate.GetValueOrDefault()).TotalDays > 90) { await Alert.ShowMessage(nameof(AppResources.DiffLessThan90DaysMessage).Translate()); return; } if (sortColumnItem != null) { _sortColumnItem = sortColumnItem; } else if (_sortColumnItem == null) { _sortColumnItem = new SortColumnItem(OrdersSortableColumns.OrderNumber, null) { Ascending = true }; } if (IsFilterDifferentFromLast(filter)) { var lines = await Api.GetReturnOrders(filter); if (!lines.Successful.GetValueOrDefault()) { await Alert.ShowMessage(lines.ExceptionMessage); return; } _previousFilter = filter; _rawList = lines.Data.ToList(); } TotalAmount = (decimal)_rawList.Sum(p => p.Amount.GetValueOrDefault()); RowCount = _rawList.Count; var sortedLines = SortList(_sortColumnItem, _rawList) .ToList(); ReturnedOrderList = new ObservableCollection <ReturnOrder>(sortedLines); NoResults = !sortedLines.Any(); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
private static ICollection <Quotation> SortList(SortColumnItem sortOrder, ICollection <Quotation> list) { switch (sortOrder.Key.ObjectToEnum <QuotesSortableColumns>()) { case QuotesSortableColumns.AccountNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.Account.Key).ToList() : list.OrderByDescending(p => p.Account.Key).ToList(); break; case QuotesSortableColumns.Account: list = sortOrder.Ascending ? list.OrderBy(p => p.Account.Name).ToList() : list.OrderByDescending(p => p.Account.Name).ToList(); break; case QuotesSortableColumns.Quotation: list = sortOrder.Ascending ? list.OrderBy(p => p.Key).ToList() : list.OrderByDescending(p => p.Key).ToList(); break; case QuotesSortableColumns.Name: list = sortOrder.Ascending ? list.OrderBy(p => p.DeliveryName).ToList() : list.OrderByDescending(p => p.DeliveryName).ToList(); break; case QuotesSortableColumns.PurchaseOrder: list = sortOrder.Ascending ? list.OrderBy(p => p.CustPurchaseOrder).ToList() : list.OrderByDescending(p => p.CustPurchaseOrder).ToList(); break; case QuotesSortableColumns.JobName: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerRef).ToList() : list.OrderByDescending(p => p.CustomerRef).ToList(); break; case QuotesSortableColumns.Plant: list = sortOrder.Ascending ? list.OrderBy(p => p.InventLocationName).ToList() : list.OrderByDescending(p => p.InventLocationName).ToList(); break; case QuotesSortableColumns.Status: list = sortOrder.Ascending ? list.OrderBy(p => p.Status).ToList() : list.OrderByDescending(p => p.Status).ToList(); break; case QuotesSortableColumns.OrderNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.Order?.Key).ToList() : list.OrderByDescending(p => p.Order?.Key).ToList(); break; case QuotesSortableColumns.ExpiryDate: list = sortOrder.Ascending ? list.OrderBy(p => p.ExpiryDate).ToList() : list.OrderByDescending(p => p.ExpiryDate).ToList(); break; case QuotesSortableColumns.DeliveryAddress: list = sortOrder.Ascending ? list.OrderBy(p => p.DeliveryAddress).ToList() : list.OrderByDescending(p => p.DeliveryAddress).ToList(); break; case QuotesSortableColumns.ConfirmationDate: list = sortOrder.Ascending ? list.OrderBy(p => p.ConfirmationDate).ToList() : list.OrderByDescending(p => p.ConfirmationDate).ToList(); break; case QuotesSortableColumns.RequestedShipDate: list = sortOrder.Ascending ? list.OrderBy(p => p.RequestedShipDate).ToList() : list.OrderByDescending(p => p.RequestedShipDate).ToList(); break; case QuotesSortableColumns.Lines: list = sortOrder.Ascending ? list.OrderBy(p => p.LinesCount).ToList() : list.OrderByDescending(p => p.LinesCount).ToList(); break; default: throw new ArgumentOutOfRangeException(); } return(list); }
public async Task Load(SettlementsFilterModel filter = null, SortColumnItem sortColumnItem = null) { try { IsBusy = true; if (sortColumnItem != null) { _sortColumnItem = sortColumnItem; } else if (_sortColumnItem == null) { _sortColumnItem = new SortColumnItem(SettlementsSortColumns.Date, null) { Ascending = true }; } filter = filter ?? new SettlementsFilterModel(); if (IsFilterDifferentFromLast(filter)) { var context = new CreditCardPaymentsQueryContext { CustomerInfo = Api.GetCustomerContext(), FromDate = filter.StartDate, ToDate = filter.EndDate, }; var result = await Api.GetPayments(context); if (!result.Successful.GetValueOrDefault()) { await Alert.DisplayApiCallError(result.ExceptionMessage, result.ValidationErrors, nameof(AppResources.ServerError)); return; } InvoiceSettlementsQueryContext settlementContext = new InvoiceSettlementsQueryContext { CustomerInfo = Api.GetCustomerContext(), FromDate = filter.StartDate, ToDate = filter.EndDate }; var settlementResult = await Api.GetInvoiceSettlements(settlementContext); if (!settlementResult.Successful.GetValueOrDefault()) { await Alert.DisplayApiCallError(settlementResult.ExceptionMessage, settlementResult.ValidationErrors); return; } var completed = result.Data.Where(p => p.Settled.GetValueOrDefault()).ToList(); PendingList = new ObservableCollection <InvoicePaymentView>(SortList(_sortColumnItem, result.Data.Except(completed))); Completed = new ObservableCollection <InvoicePaymentView>(SortList(_sortColumnItem, completed)); SettledList = new ObservableCollection <InvoiceSettlement>(settlementResult.Data); _previousFilter = filter; return; } PendingList = new ObservableCollection <InvoicePaymentView>(SortList(_sortColumnItem, _pendingList)); Completed = new ObservableCollection <InvoicePaymentView>(SortList(_sortColumnItem, _completed)); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
private static ICollection <SalesOrder> SortList(SortColumnItem sortOrder, ICollection <SalesOrder> list) { switch (sortOrder.Key.ObjectToEnum <OrdersSortableColumns>()) { case OrdersSortableColumns.AccountNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.Account.Key).ToList() : list.OrderByDescending(p => p.Account.Key).ToList(); break; case OrdersSortableColumns.Account: list = sortOrder.Ascending ? list.OrderBy(p => p.Account.Name).ToList() : list.OrderByDescending(p => p.Account.Name).ToList(); break; case OrdersSortableColumns.PurchaseOrder: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerPurchaseOrderNo).ToList() : list.OrderByDescending(p => p.CustomerPurchaseOrderNo).ToList(); break; case OrdersSortableColumns.JobName: list = sortOrder.Ascending ? list.OrderBy(p => p.CustomerRef).ToList() : list.OrderByDescending(p => p.CustomerRef).ToList(); break; case OrdersSortableColumns.Plant: list = sortOrder.Ascending ? list.OrderBy(p => p.InventLocationName).ToList() : list.OrderByDescending(p => p.InventLocationName).ToList(); break; case OrdersSortableColumns.Status: list = sortOrder.Ascending ? list.OrderBy(p => p.SalesOrderStatus).ToList() : list.OrderByDescending(p => p.SalesOrderStatus).ToList(); break; case OrdersSortableColumns.OrderNumber: list = sortOrder.Ascending ? list.OrderBy(p => p.Key).ToList() : list.OrderByDescending(p => p.Key).ToList(); break; case OrdersSortableColumns.DeliveryDate: list = sortOrder.Ascending ? list.OrderBy(p => p.DeliveryDate).ToList() : list.OrderByDescending(p => p.DeliveryDate).ToList(); break; case OrdersSortableColumns.Lines: list = sortOrder.Ascending ? list.OrderBy(p => p.LinesCount).ToList() : list.OrderByDescending(p => p.LinesCount).ToList(); break; case OrdersSortableColumns.Amount: list = sortOrder.Ascending ? list.OrderBy(p => p.NetAmount).ToList() : list.OrderByDescending(p => p.NetAmount).ToList(); break; case OrdersSortableColumns.OrderDate: list = sortOrder.Ascending ? list.OrderBy(p => p.OrderDate).ToList() : list.OrderByDescending(p => p.OrderDate).ToList(); break; case OrdersSortableColumns.Invoices: list = sortOrder.Ascending ? list.OrderBy(p => p.Invoices.Count).ToList() : list.OrderByDescending(p => p.Invoices.Count).ToList(); break; case OrdersSortableColumns.PackingSlips: list = sortOrder.Ascending ? list.OrderBy(p => p.PackingSlips.Count).ToList() : list.OrderByDescending(p => p.PackingSlips.Count).ToList(); break; default: throw new ArgumentOutOfRangeException(); } return(list); }
private void OnChangeSortOrder(SortColumnItem sortColumn) { if (sortColumn == null || _manifests == null) { return; } var list = _manifests.ToList(); switch (sortColumn.Key.ObjectToEnum <DrvManifestDetailsSortColumns>()) { case DrvManifestDetailsSortColumns.PackingSlips: list = sortColumn.Ascending ? list.OrderBy(p => p.PackingSlipId).ToList() : list.OrderByDescending(p => p.PackingSlipId).ToList(); break; case DrvManifestDetailsSortColumns.CustomerName: list = sortColumn.Ascending ? list.OrderBy(p => p.CustName).ToList() : list.OrderByDescending(p => p.CustName).ToList(); break; case DrvManifestDetailsSortColumns.Safety: list = sortColumn.Ascending ? list.OrderBy(p => p.SafetyIndicator).ToList() : list.OrderByDescending(p => p.SafetyIndicator).ToList(); break; case DrvManifestDetailsSortColumns.Status: list = sortColumn.Ascending ? list.OrderBy(p => p.Status).ToList() : list.OrderByDescending(p => p.Status).ToList(); break; case DrvManifestDetailsSortColumns.DeliveryDate: list = sortColumn.Ascending ? list.OrderBy(p => p.DeliveryDate).ToList() : list.OrderByDescending(p => p.DeliveryDate).ToList(); break; case DrvManifestDetailsSortColumns.CustomerAccount: list = sortColumn.Ascending ? list.OrderBy(p => p.CustAccount).ToList() : list.OrderByDescending(p => p.CustAccount).ToList(); break; case DrvManifestDetailsSortColumns.Street: list = sortColumn.Ascending ? list.OrderBy(p => p.Street).ToList() : list.OrderByDescending(p => p.Street).ToList(); break; case DrvManifestDetailsSortColumns.City: list = sortColumn.Ascending ? list.OrderBy(p => p.City).ToList() : list.OrderByDescending(p => p.City).ToList(); break; case DrvManifestDetailsSortColumns.ZipCode: list = sortColumn.Ascending ? list.OrderBy(p => p.ZipCode).ToList() : list.OrderByDescending(p => p.ZipCode).ToList(); break; case DrvManifestDetailsSortColumns.StopNumber: list = sortColumn.Ascending ? list.OrderBy(p => p.StopNumber).ToList() : list.OrderByDescending(p => p.StopNumber).ToList(); break; case DrvManifestDetailsSortColumns.State: list = sortColumn.Ascending ? list.OrderBy(p => p.State).ToList() : list.OrderByDescending(p => p.State).ToList(); break; case DrvManifestDetailsSortColumns.ClockIn: list = sortColumn.Ascending ? list.OrderBy(p => p.ClockInDateTime.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.ClockInDateTime.GetValueOrDefault()).ToList(); break; case DrvManifestDetailsSortColumns.ClockOut: list = sortColumn.Ascending ? list.OrderBy(p => p.ClockOutDateTime.GetValueOrDefault()).ToList() : list.OrderByDescending(p => p.ClockOutDateTime.GetValueOrDefault()).ToList(); break; default: throw new ArgumentOutOfRangeException(); } _currentSortColumn = sortColumn; Manifests = new ObservableCollection <ShipManifestDetail>(list); }