Esempio n. 1
0
        public async Task ShouldReturnCareChargePackages()
        {
            // Arrange
            var stubbedEntities = _fixture.Build <PagedList <CareChargePackagesDomain> >()
                                  // .OmitAutoProperties()
                                  .Without(p => p.Capacity)
                                  .Create();
            var requestParam = new CareChargePackagesParameters()
            {
                PageSize = 10, PageNumber = 1
            };


            _mockGateway.Setup(x => x.GetCareChargePackages(requestParam))
            .ReturnsAsync(stubbedEntities);

            // Act
            var expectedResponse = new PagedResponse <CareChargePackagesResponse>
            {
                PagingMetaData = stubbedEntities.PagingMetaData,
                Data           = stubbedEntities.ToResponse()
            };
            var response = await _getCareChargePackagesUseCase.GetCareChargePackages(requestParam).ConfigureAwait(false);

            // Assert
            _mockGateway.Verify(x => x.GetCareChargePackages
                                    (It.Is <CareChargePackagesParameters>(d => d.PageSize == 10 && d.PageNumber == 1)));

            response.Should().BeEquivalentTo(expectedResponse);
        }
 private async Task <int> GetCareChargePackagesCount(CareChargePackagesParameters parameters)
 {
     return(await _dbContext.CarePackages
            .FilterCareChargeCarePackageList(parameters.Status, parameters.ModifiedBy, parameters.OrderByDate, parameters.SearchTerm)
            .Where(c => c.Settings.IsS117ClientConfirmed == false)
            .CountAsync());
 }
        public async Task <ActionResult <PagedResponse <CareChargePackagesResponse> > > GetCareChargePackages([FromQuery] CareChargePackagesParameters parameters)
        {
            var result = await _getCareChargePackagesUseCase.GetCareChargePackages(parameters).ConfigureAwait(false);

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(result.PagingMetaData));
            return(Ok(result));
        }
        public async Task <PagedResponse <CareChargePackagesResponse> > GetCareChargePackages(CareChargePackagesParameters parameters)
        {
            var result = await _careChargesGateway.GetCareChargePackages(parameters).ConfigureAwait(false);

            return(new PagedResponse <CareChargePackagesResponse>
            {
                PagingMetaData = result.PagingMetaData,
                Data = result.ToResponse()
            });
        }
 private async Task <List <CareChargePackagesDomain> > GetCareChargePackagesList(CareChargePackagesParameters parameters)
 {
     return(await _dbContext.CarePackages
            .FilterCareChargeCarePackageList(parameters.Status, parameters.ModifiedBy, parameters.OrderByDate, parameters.SearchTerm)
            .Where(c => c.Settings.IsS117ClientConfirmed == false)
            .Include(item => item.Settings)
            .Include(item => item.ServiceUser)
            .Include(item => item.Updater)
            .Include(item => item.Reclaims)
            .Select(c => new CareChargePackagesDomain
     {
         Status = c.Reclaims.Any(r => r.Type == ReclaimType.CareCharge && r.SubType != ReclaimSubType.CareChargeProvisional) ? "Existing" : "New",
         ServiceUser = $"{c.ServiceUser.FirstName} {c.ServiceUser.LastName}",
         ServiceUserId = c.ServiceUserId,
         DateOfBirth = c.ServiceUser.DateOfBirth,
         Address = $"{c.ServiceUser.AddressLine1} {c.ServiceUser.AddressLine2} {c.ServiceUser.AddressLine3} {c.ServiceUser.County} {c.ServiceUser.Town} {c.ServiceUser.PostCode}",
         HackneyId = c.ServiceUser.HackneyId,
         PackageType = c.PackageType.GetDisplayName(),
         PackageId = c.Id,
         IsS117Client = c.Settings.IsS117Client,
         StartDate = c.Reclaims.OrderBy(x => x.StartDate).FirstOrDefault().StartDate,
         LastModified = c.DateUpdated,
         ModifiedBy = c.Updater.Name
     })
            .ToListAsync());
 }
        public async Task <PagedList <CareChargePackagesDomain> > GetCareChargePackages(CareChargePackagesParameters parameters)
        {
            var careChargePackagesCount = await GetCareChargePackagesCount(parameters);

            var careChargePackagesList = await GetCareChargePackagesList(parameters);

            var paginatedCareChargePackageList = careChargePackagesList
                                                 .Skip((parameters.PageNumber - 1) * parameters.PageSize)
                                                 .Take(parameters.PageSize);

            return(PagedList <CareChargePackagesDomain> .ToPagedList(paginatedCareChargePackageList, careChargePackagesCount, parameters.PageNumber, parameters.PageSize));
        }