コード例 #1
0
ファイル: LeaseServiceTest.cs プロジェクト: asanchezr/PSP
        public void Get_Leases_Filter(LeaseFilter filter, int expectedCount)
        {
            // Arrange
            var helper = new TestHelper();
            var user   = PrincipalHelper.CreateForPermission(Permissions.LeaseView);
            var elease = EntityHelper.CreateLease(456, lFileNo: "123", tenantLastName: "tenant", addTenant: true);

            elease.Id             = 1;
            elease.OrigExpiryDate = new DateTime(2000, 1, 1);
            elease.OrigStartDate  = new DateTime(2000, 1, 1);

            var context = helper.CreatePimsContext(user, true);

            context.AddAndSaveChanges(elease);

            var service = helper.CreateRepository <LeaseRepository>(user);

            // Act
            var result = service.GetPage(filter);

            // Assert
            Assert.NotNull(result);
            Assert.IsAssignableFrom <Paged <Entity.PimsLease> >(result);
            Assert.Equal(expectedCount, result.Items.Count);
        }
コード例 #2
0
        public List <LeaseModel> GetLeaList(DataProvider dp, LeaseFilter filter, out int total, bool IsPage = true)
        {
            var list = from lea in dp.PM_Lease.Where(m => !m.IsDel)
                       join dic in dp.System_DicItem.Where(m => !m.IsDel) on lea.LeaseType equals dic.Id
                       select new LeaseModel()
            {
                Id            = lea.Id,
                IsEnabled     = lea.IsEnabled,
                LeaseName     = lea.LeaseName,
                LeaseType     = lea.LeaseType,
                LeaseTypeDesc = dic.ItemDesc,
                Sort          = lea.Sort,
                CreateTime    = lea.CreateTime
            };

            if (filter.LeaseName.IsNotNullOrWhiteSpace())
            {
                list = list.Where(m => m.LeaseName.Contains(filter.LeaseName));
            }

            if (filter.LeaseType.IsNotNullAndCountGtZero())
            {
                list = list.Where(m => filter.LeaseType.Contains(m.LeaseType));
            }
            list  = list.OrderBy(m => m.Sort).ThenByDescending(m => m.CreateTime);
            total = list.Count();
            if (IsPage)
            {
                return(list.Skip(filter.Skip).Take(filter.PageSize).ToList());
            }
            else
            {
                return(list.ToList());
            }
        }
コード例 #3
0
ファイル: LeaseBusiness.cs プロジェクト: makotowzhang/OA
 public List <LeaseModel> GetLeaList(LeaseFilter filter, out int total, bool isPage = true)
 {
     using (DataProvider dp = new DataProvider())
     {
         var list = data.GetLeaList(dp, filter, out total, isPage);
         return(Mapper.Map <List <LeaseModel> >(list));
     }
 }
コード例 #4
0
ファイル: LeaseRepository.cs プロジェクト: asanchezr/PSP
        /// <summary>
        /// Get an array of leases within the specified filters.
        /// Note that the 'leaseFilter' will control the 'page' and 'quantity'.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public IEnumerable <PimsLease> Get(LeaseFilter filter, bool loadPayments = false)
        {
            this.User.ThrowIfNotAuthorized(Permissions.LeaseView);
            filter.ThrowIfNull(nameof(filter));
            if (!filter.IsValid())
            {
                throw new ArgumentException("Argument must have a valid filter", nameof(filter));
            }

            var query = this.Context.GenerateLeaseQuery(filter, loadPayments);

            var leases = query.OrderBy(l => l.LeaseId).ToArray();

            return(leases);
        }
コード例 #5
0
ファイル: LeaseRepository.cs プロジェクト: asanchezr/PSP
        /// <summary>
        /// Get a page with an array of leases within the specified filters.
        /// Note that the 'leaseFilter' will control the 'page' and 'quantity'.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public Paged <PimsLease> GetPage(LeaseFilter filter)
        {
            this.User.ThrowIfNotAuthorized(Permissions.LeaseView);
            filter.ThrowIfNull(nameof(filter));
            if (!filter.IsValid())
            {
                throw new ArgumentException("Argument must have a valid filter", nameof(filter));
            }

            var skip  = (filter.Page - 1) * filter.Quantity;
            var query = this.Context.GenerateLeaseQuery(filter);
            var items = query
                        .OrderBy(l => l.LeaseId)
                        .Skip(skip)
                        .Take(filter.Quantity)
                        .ToArray();


            return(new Paged <PimsLease>(items, filter.Page, filter.Quantity, query.Count()));
        }
コード例 #6
0
ファイル: LeaseController.cs プロジェクト: makotowzhang/OA
        public ActionResult GetLeaList(LeaseFilter filter)
        {
            var data = business.GetLeaList(filter, out int total);

            return(Json(new TableDataModel(total, data)));
        }