Ejemplo 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();
     }
 }
Ejemplo n.º 2
0
        private static IQueryable<Reclamation> ApplyReclamationFilter( IQueryable<Reclamation> reclamations, ReclamationFilter filter )
        {
            if ( filter.ReclamationType.HasValue )
            {
                reclamations = reclamations.Where( r => r.ReclamationType == filter.ReclamationType.Value );
            }
            if ( filter.ReclamationDateBegin.HasValue )
            {
                reclamations = reclamations.Where( r => r.ReclamationDate >= filter.ReclamationDateBegin.Value );
            }
            if ( filter.ReclamationDateEnd.HasValue )
            {
                reclamations = reclamations.Where( r => r.ReclamationDate <= filter.ReclamationDateEnd.Value );
            }

            return reclamations;
        }
Ejemplo n.º 3
0
 public static int GetReclamationsCount( string clientId, ReclamationFilter filter )
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         var reclamations = dc.DataContext.Reclamations.Where( r => r.ClientID == clientId );
         if ( filter != null )
         {
             reclamations = ApplyReclamationFilter( reclamations, filter );
         }
         return reclamations.Count();
     }
 }