private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            var         menu    = sender as MenuItem;
            var         parent  = menu.Parent as MenuItem;
            var         orders  = Enum.GetNames(typeof(Order));
            var         filters = Enum.GetNames(typeof(SortFilters));
            Order       ord     = Order.DSC;
            SortFilters sort    = SortFilters.Date;

            foreach (var order in orders)
            {
                if ((string)menu.Header == order)
                {
                    Enum.TryParse(order, out ord);
                    break;
                }
            }
            foreach (var filt in filters)
            {
                if ((string)parent.Header == filt)
                {
                    Enum.TryParse(filt, out sort);
                    break;
                }
            }
            msg = features.SortBy(sort, ord);
            mails.Dispatcher.Invoke(() => mails.ShowMessageList(messages, msg));
        }
Exemple #2
0
 /// <summary>
 /// Add order descending by the specified property.
 /// </summary>
 /// <returns>
 /// SortBuilder of TPropEnum, TQuery, TQueryBuilder
 /// </returns>
 public SortBuilder <TPropEnum, TQuery, TQueryBuilder> OrderByDescending(TPropEnum prop)
 {
     if (Sorting == null)
     {
         Sorting = new SortFilters <TPropEnum>();
     }
     Sorting.Add(SortFilter.New(prop, SortDirection.Descending));
     return(this);
 }
Exemple #3
0
 /// <summary>
 /// Add order ascending by the specified property.
 /// </summary>
 /// <returns>
 /// SortBuilder of TPropEnum, TQuery, TQueryBuilder
 /// </returns>
 public SortBuilder <TPropEnum, TQuery, TQueryBuilder> OrderBy(TPropEnum prop)
 {
     if (Sorting == null)
     {
         Sorting = new SortFilters <TPropEnum>();
     }
     Sorting.Add(SortFilter.New(prop));
     return(this);
 }
Exemple #4
0
 public Suppliers_ArchiveRepository()
 {
     //this is the unique id for the model to which this repository belongs to. used to find the correct connection string
     ModelId = RepoLookup.ModelId.WorldWideImporters;
     //this is the unique id for the entity. used to retrieve EntityInfo object from the RepoLookup.EntityId
     EntityId = RepoLookup.EntityId.WorldWideImporters_Purchasing_Suppliers_Archive;
     //tables with triggers have limitations that need to be accounted for
     HasTriggers = false;
     #region Default Sorting
     //there was no default sort found in the store. keep this variable as a placeholder.
     //it is also possible to add a constructor and fill this collection with a custom sort.
     DefaultSort = new SortFilters <Suppliers_ArchiveProperty>(0);
     #endregion
 }
Exemple #5
0
        protected TEntity SelectSingle(QueryFilters <TPropEnum> where, SortFilters <TPropEnum> orderby)
        {
            var result = SelectMany(where, orderby, null, 0);

            if (!(result?.Count > 0))
            {
                return(default(TEntity));
            }
            if (result.Count > 1)
            {
                throw new InvalidOperationException($"More than one record was found at the store for entity: {typeof(TEntity).FullName}");
            }
            return(result[0]);
        }
 public TrackRepository()
 {
     //this is the unique id for the model to which this repository belongs to. used to find the correct connection string
     ModelId = RepoLookup.ModelId.MainDb;
     //this is the unique id for the entity. used to retrieve EntityInfo object from the RepoLookup.EntityId
     EntityId = RepoLookup.EntityId.MainDb_Media_Track;
     //tables with triggers have limitations that need to be accounted for
     HasTriggers = false;
     #region Default Sorting
     //this is the PK (PK__Track__7A74F8E00EA330E9) sorting. used as default for method overloads that DO NOT take a SortFilters parameter
     DefaultSort = new SortFilters <TrackProperty>(1)
     {
         SortFilter.New(TrackProperty.TrackId),
     };
     #endregion
 }
Exemple #7
0
 public InvoiceRepository()
 {
     //this is the unique id for the model to which this repository belongs to. used to find the correct connection string
     ModelId = RepoLookup.ModelId.MainDb;
     //this is the unique id for the entity. used to retrieve EntityInfo object from the RepoLookup.EntityId
     EntityId = RepoLookup.EntityId.MainDb_Accounting_Invoice;
     //tables with triggers have limitations that need to be accounted for
     HasTriggers = false;
     #region Default Sorting
     //this is the PK (PK__Invoice__D796AAB51A14E395) sorting. used as default for method overloads that DO NOT take a SortFilters parameter
     DefaultSort = new SortFilters <InvoiceProperty>(1)
     {
         SortFilter.New(InvoiceProperty.InvoiceId),
     };
     #endregion
 }
Exemple #8
0
 public ColorRepository()
 {
     //this is the unique id for the model to which this repository belongs to. used to find the correct connection string
     ModelId = RepoLookup.ModelId.WorldWideImporters;
     //this is the unique id for the entity. used to retrieve EntityInfo object from the RepoLookup.EntityId
     EntityId = RepoLookup.EntityId.WorldWideImporters_Warehouse_Color;
     //tables with triggers have limitations that need to be accounted for
     HasTriggers = false;
     #region Default Sorting
     //this is the PK (PK_Warehouse_Colors) sorting. used as default for method overloads that DO NOT take a SortFilters parameter
     DefaultSort = new SortFilters <ColorProperty>(1)
     {
         SortFilter.New(ColorProperty.ColorID),
     };
     #endregion
 }
 public CustomerRepository()
 {
     //this is the unique id for the model to which this repository belongs to. used to find the correct connection string
     ModelId = RepoLookup.ModelId.MainDb;
     //this is the unique id for the entity. used to retrieve EntityInfo object from the RepoLookup.EntityId
     EntityId = RepoLookup.EntityId.MainDb_People_Customer;
     //tables with triggers have limitations that need to be accounted for
     HasTriggers = false;
     #region Default Sorting
     //this is the PK (PK__Customer__A4AE64D8164452B1) sorting. used as default for method overloads that DO NOT take a SortFilters parameter
     DefaultSort = new SortFilters <CustomerProperty>(1)
     {
         SortFilter.New(CustomerProperty.CustomerId),
     };
     #endregion
 }
 public EmployeeRepository()
 {
     //this is the unique id for the model to which this repository belongs to. used to find the correct connection string
     ModelId = RepoLookup.ModelId.MainDb;
     //this is the unique id for the entity. used to retrieve EntityInfo object from the RepoLookup.EntityId
     EntityId = RepoLookup.EntityId.MainDb_People_Employee;
     //tables with triggers have limitations that need to be accounted for
     HasTriggers = false;
     #region Default Sorting
     //this is the PK (PK__Employee__7AD04F111273C1CD) sorting. used as default for method overloads that DO NOT take a SortFilters parameter
     DefaultSort = new SortFilters <EmployeeProperty>(1)
     {
         SortFilter.New(EmployeeProperty.EmployeeId),
     };
     #endregion
 }
Exemple #11
0
        /// <summary>
        /// sorts list ascending
        /// </summary>
        /// <param name="filter"> object that method sorts by</param>
        private void SortAsc(SortFilters filter)
        {
            switch (filter)
            {
            case SortFilters.Subject:
                messages.Sort((m1, m2) => m1.Subject.CompareTo(m2.Subject));
                break;

            case SortFilters.Date:
                messages.Sort((m1, m2) => m1.Date.CompareTo(m2.Date));
                break;

            case SortFilters.From:
                messages.Sort((m1, m2) => m1.From.CompareTo(m2.From));
                break;
            }
        }
Exemple #12
0
        protected List <TEntity> SelectMany(QueryFilters <TPropEnum> filters, SortFilters <TPropEnum> sortFilters, PaginationSettings pagination, int topCount)
        {
            var resultSets = new object[1];

            void materialize(SqlDataReader r)
            {
                MaterializeResult(r, MaterializeEntity, resultSets, pagination);
            }

            Database.Select(ModelId, EntityId, topCount, filters?.IFilters, sortFilters?.IFilters, pagination, null, materialize);
            var result = BuildEntityTree(resultSets);//build the tree AFTER the reader is done and disposed.

            if (result?.Count > 0)
            {
                return(result);
            }
            return(null);
        }
Exemple #13
0
        /// <summary>
        /// Sorts messages by two filters
        /// </summary>
        /// <param name="filter"> object that method sorts by</param>
        /// <param name="sort"> order of sorting</param>
        /// <returns> List of sorted messages</returns>
        public List <MimeMessage> SortBy(SortFilters filter, Order sort)
        {
            switch (filter)
            {
            case SortFilters.Subject:
                if (sort == Order.ASC)
                {
                    SortAsc(filter);
                }
                else
                {
                    SortDsc(filter);
                }
                break;

            case SortFilters.Date:
                //  Array.Sort<MimeMessage, int>(messages.ToArray(), uids.ToArray(), Sorter.SortByDates());
                if (sort == Order.ASC)
                {
                    SortAsc(filter);
                }
                else
                {
                    SortDsc(filter);
                }
                break;

            case SortFilters.From:
                if (sort == Order.ASC)
                {
                    SortAsc(filter);
                }
                else
                {
                    SortDsc(filter);
                }
                break;
            }
            return(messages);
        }