Esempio n. 1
0
        public async Task Load(QuoteFilter filter = null, SortColumnItem sortColumnItem = null)
        {
            try
            {
                IsBusy     = true;
                ShowFilter = false;
                filter     = filter ?? _previousFilter ?? new QuoteFilter
                {
                    StartDate = DateTime.Today.AddDays(-900),
                    EndDate   = DateTime.Today
                };
                var sortColumn = sortColumnItem
                                 ?? _previousSortColumnItem
                                 ?? new SortColumnItem(QuotesSortableColumns.Quotation, null)
                {
                    Ascending = true
                };

                IEnumerable <Quotation> lines;
                if (IsFilterDifferentFromLast(filter))
                {
                    lines = await Api.GetQuotes(filter);

                    _previousFilter = filter;
                }
                else
                {
                    lines = _list;
                }
                var sortedLines = SortList(sortColumn, lines.ToList())
                                  .Take(filter.SelectedQty)
                                  .ToList();


                List      = new ObservableCollection <Quotation>(sortedLines);
                NoResults = !sortedLines.Any();
            }
            catch (Exception e)
            {
                await Alert.DisplayError(e);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 2
0
        private void Init()
        {
            Filter  = new QuoteFilter();
            QtyList = new ObservableCollection <int> {
                50, 100, 150, 200
            };

            Filter.SelectedQty = _qtyList.First();
            StatusList         = new ObservableCollection <KeyValuePair <QuotationsQueryContextStatus, string> >
            {
                new KeyValuePair <QuotationsQueryContextStatus, string>(QuotationsQueryContextStatus.None,
                                                                        nameof(AppResources.SelectStatus).Translate()),
                new KeyValuePair <QuotationsQueryContextStatus, string>(QuotationsQueryContextStatus.Created,
                                                                        nameof(AppResources.Created).Translate()),
                new KeyValuePair <QuotationsQueryContextStatus, string>(QuotationsQueryContextStatus.Sent,
                                                                        nameof(AppResources.Sent).Translate()),
                new KeyValuePair <QuotationsQueryContextStatus, string>(QuotationsQueryContextStatus.Confirmed,
                                                                        nameof(AppResources.Confirmed).Translate()),
            };
            Filter.SelectedStatus = _statusList.First();


            Filter.StartDate = DateTime.Today.AddDays(-900);
            Filter.EndDate   = DateTime.Today;

            SortColumns = new ObservableCollection <SortColumnItem>
            {
                new SortColumnItem(QuotesSortableColumns.AccountNumber, nameof(AppResources.AccountNumber).Translate()),
                new SortColumnItem(QuotesSortableColumns.Account, nameof(AppResources.Account).Translate()),
                new SortColumnItem(QuotesSortableColumns.Quotation, nameof(AppResources.Quotation).Translate()),
                new SortColumnItem(QuotesSortableColumns.Name, nameof(AppResources.DeliveryName).Translate()),
                new SortColumnItem(QuotesSortableColumns.PurchaseOrder, nameof(AppResources.PurchaseOrder).Translate()),
                new SortColumnItem(QuotesSortableColumns.JobName, nameof(AppResources.JobName).Translate()),
                new SortColumnItem(QuotesSortableColumns.Plant, nameof(AppResources.TrulitePlant).Translate()),
                new SortColumnItem(QuotesSortableColumns.Status, nameof(AppResources.Status).Translate()),
                new SortColumnItem(QuotesSortableColumns.OrderNumber, nameof(AppResources.OrderNumber).Translate()),
                new SortColumnItem(QuotesSortableColumns.ExpiryDate, nameof(AppResources.ExpiryDate).Translate()),
                new SortColumnItem(QuotesSortableColumns.DeliveryAddress, nameof(AppResources.DeliveryAddress).Translate()),
                new SortColumnItem(QuotesSortableColumns.ConfirmationDate, nameof(AppResources.ConfirmationDate).Translate()),
                new SortColumnItem(QuotesSortableColumns.RequestedShipDate, nameof(AppResources.RequestedShipDate).Translate()),
                new SortColumnItem(QuotesSortableColumns.Lines, nameof(AppResources.LinesCamelCase).Translate()),
            };
            Ascending = true;
            Children[0].BindingContext = this;
            SelectedSortColumn         = _sortColumns[2];
        }
Esempio n. 3
0
        private bool IsFilterDifferentFromLast(QuoteFilter currentFilter)
        {
            if (_previousFilter == null)
            {
                return(true);
            }
            if (_previousFilter.Number != currentFilter.Number)
            {
                return(true);
            }
            if (_previousFilter.AccountNumber != currentFilter.AccountNumber)
            {
                return(true);
            }
            if (_previousFilter.SalesOrderNumber != currentFilter.SalesOrderNumber)
            {
                return(true);
            }
            if (_previousFilter.EndDate != currentFilter.EndDate)
            {
                return(true);
            }
            if (_previousFilter.StartDate != currentFilter.StartDate)
            {
                return(true);
            }
            if (_previousFilter.SelectedStatus.Key != currentFilter.SelectedStatus.Key)
            {
                return(true);
            }
            if (_previousFilter.SelectedQty != currentFilter.SelectedQty)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
 private async Task OnSearch(QuoteFilter arg)
 {
     ShowFilter = false;
     await Load(arg);
 }