Example #1
0
        public List<DriverDto> GetAll(string sortBy, string sortDirection, string criteria, int pageIndex, int pageSize, out int pageTotal)
        {
            var pagingCriteria = new PagingCriteria();

            pagingCriteria.PageNumber = pageIndex;
            pagingCriteria.PageSize = pageSize;
            pagingCriteria.SortBy = !string.IsNullOrEmpty(sortBy) ? sortBy : "CreatedDate";
            pagingCriteria.SortDirection = !string.IsNullOrEmpty(sortDirection) ? sortDirection : "DESC";

            Expression<Func<Driver, bool>> where = x => ((string.IsNullOrEmpty(criteria) || x.Name.Contains(criteria)));

            var results = Uow.Drivers.GetAll(pagingCriteria, where, x => x.Truck);

            pageTotal = results.PagedMetadata.TotalItemCount;

            return results.Entities.Project().To<DriverDto>().ToList();
        }
Example #2
0
        public List<OrderDto> GetAll(string sortBy, string sortDirection, Guid[] statusId, DateTime? from, DateTime? to, int pageIndex, int pageSize, out int pageTotal)
        {
            var pagingCriteria = new PagingCriteria();

            pagingCriteria.PageNumber = pageIndex;
            pagingCriteria.PageSize = pageSize;
            pagingCriteria.SortBy = !string.IsNullOrEmpty(sortBy) ? sortBy : "CreatedDate";
            pagingCriteria.SortDirection = !string.IsNullOrEmpty(sortDirection) ? sortDirection : "DESC";

            Expression<Func<Order, bool>> where = x => statusId.Any(y => y == x.OrderStatusId)
                                                   && (!from.HasValue || x.CreatedDate >= from)
                                                   && (!to.HasValue || x.CreatedDate <= to);

            var results = Uow.Orders.GetAll(pagingCriteria, where,
                x => x.Client,
                x => x.Truck,
                x => x.Driver,
                x => x.OrderStatus,
                x => x.Deposit);

            pageTotal = results.PagedMetadata.TotalItemCount;

            return results.Entities.AsEnumerable().Select(Mapper.Map<Order, OrderDto>).ToList();
        }