Exemplo n.º 1
0
 public static Reclamation[] GetReclamations( string clientId, ReclamationFilter filter, ReclamationSortFields sortField, int startIndex, int size )
 {
     using ( var dc = new DCFactory<StoreDataContext>() )
     {
         //TODO add DatatLoadOptions if required
         //DataLoadOptions options = new DataLoadOptions();
         //options.LoadWith<OrderLine>( l => l.OrderLineStatusChanges );
         //options.LoadWith<OrderLine>( l => l.Order );
         //dc.LoadOptions = options;
         var reclamations = dc.DataContext.Reclamations.Where( r => r.ClientID == clientId );
         if ( filter != null )
         {
             reclamations = ApplyReclamationFilter( reclamations, filter );
         }
         reclamations = ApplyReclamationSort( reclamations, sortField );
         return reclamations.Skip( startIndex ).Take( size ).ToArray();
     }
 }
Exemplo n.º 2
0
 private static IQueryable<Reclamation> ApplyReclamationSort( IQueryable<Reclamation> reclamations, ReclamationSortFields sortField )
 {
     switch ( sortField )
     {
         case ReclamationSortFields.ReclamationDateAsc: reclamations = reclamations.OrderBy( r => r.ReclamationDate ); break;
         case ReclamationSortFields.ReclamationDateDesc: reclamations = reclamations.OrderByDescending( r => r.ReclamationDate ); break;
         case ReclamationSortFields.Status: reclamations = reclamations.OrderBy( r => r.CurrentStatus ); break;
     }
     return reclamations;
 }