public IEnumerable <DeliveryZone> Get(DeliveryZoneFilter filter) { try { var query = Db.Set <DeliveryZone>().AsQueryable(); //TODO: dependencies. if (!string.IsNullOrEmpty(filter.Sidx)) { query = filter.Sord.Equals("desc", StringComparison.OrdinalIgnoreCase) ? query.OrderByDescending(filter.Sidx) : query.OrderBy(filter.Sidx); } if (filter.Page != 0 && filter.Rows != 0) { return(query.Skip(filter.Rows * (filter.Page - 1)).Take(filter.Rows)); } return(query); } catch (Exception ex) { LogEventManager.Logger.Error(ex.Message, ex); throw; } }
public void Get(DbContextOptions <OrderContext> options, DeliveryZoneFilter filter, int expectedResult) { try { using (var db = new OrderContext(options)) { IEnumerable <DeliveryZone> result = new List <DeliveryZone>(); var repository = new DeliveryZoneRepository(db); Assert.DoesNotThrow(() => result = repository.Get(filter)); Assert.True(result != null && result.Count() == expectedResult); } } catch (Exception ex) { LogEventManager.Logger.Error(ex.Message, ex); throw; } }