public async Task UpdateCarePackageDetailsShouldFailIfAnpDatesOutsideCoreCostDates()
        {
            var package = _generator.CreateCarePackage();
            var details = _generator.CreateCarePackageDetails(package, 1, PackageDetailType.AdditionalNeed);

            var request = new CarePackageBrokerageCreationRequest
            {
                CoreCost   = 123.45m,
                StartDate  = DateTimeOffset.UtcNow.Date.AddDays(-30),
                EndDate    = DateTimeOffset.UtcNow.Date.AddDays(30),
                SupplierId = 2,
                Details    = details.ToRequest().ToList()
            };

            request.Details.Add(TestDataHelper.CreateCarePackageDetailDomainList(2, PackageDetailType.AdditionalNeed).First().ToRequest());

            foreach (var detail in request.Details)
            {
                detail.Cost     += 10.0m;
                detail.StartDate = request.StartDate?.AddDays(-40);
                detail.EndDate   = request.EndDate?.AddDays(40);
            }

            var response = await _fixture.RestClient
                           .PutAsync <object>($"api/v1/care-packages/{package.Id}/details", request);

            response.Message.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity);
        }
        private static void VerifyPackageDetails(CarePackage package, CarePackageBrokerageCreationRequest request)
        {
            package.SupplierId.Should().Be(request.SupplierId);
            package.Details.Count.Should().Be(request.Details.Count + 1); // +1 for core cost detail

            var coreCostDetail = package.Details.FirstOrDefault(d => d.Type is PackageDetailType.CoreCost);

            coreCostDetail.Should().NotBeNull();
            coreCostDetail?.Cost.Should().Be(request.CoreCost);
            coreCostDetail?.CostPeriod.Should().Be(PaymentPeriod.Weekly);
            coreCostDetail?.StartDate.Should().Be(request.StartDate.Value);
            coreCostDetail?.EndDate.Should().Be(request.EndDate);

            foreach (var requestedDetail in request.Details)
            {
                package.Details.Should().ContainEquivalentOf(requestedDetail, opt => opt.Excluding(d => d.Id));
            }
        }
        public async Task ShouldUpdateCarePackageDetails()
        {
            var package = _generator.CreateCarePackage();
            var details = _generator.CreateCarePackageDetails(package, 5, PackageDetailType.AdditionalNeed);

            var request = new CarePackageBrokerageCreationRequest
            {
                CoreCost   = 123.45m,
                StartDate  = DateTimeOffset.UtcNow.Date.AddDays(-500),
                SupplierId = 2,
                Details    = details.ToRequest().ToList()
            };

            // Imitate remove, create and update at once
            request.Details.RemoveAt(1);
            request.Details.RemoveAt(2);
            request.Details.Add(TestDataHelper.CreateCarePackageDetailDomainList(1, PackageDetailType.AdditionalNeed).First().ToRequest());

            foreach (var detail in request.Details)
            {
                detail.Cost     += 1.0m;
                detail.StartDate = detail.StartDate?.AddDays(-10) ?? DateTimeOffset.UtcNow.Date.AddDays(-10);
                detail.EndDate   = detail.EndDate?.AddDays(-10) ?? DateTimeOffset.UtcNow.Date.AddDays(-10);
            }

            var response = await _fixture.RestClient
                           .PutAsync <object>($"api/v1/care-packages/{package.Id}/details", request);

            package = _fixture.DatabaseContext.CarePackages
                      .Include(p => p.Details)
                      .First(p => p.Id == package.Id);

            response.Message.StatusCode.Should().Be(HttpStatusCode.OK);

            VerifyPackageDetails(package, request);
        }
コード例 #4
0
        public async Task <ActionResult> CreateCarePackageBrokerageInfo(Guid packageId, CarePackageBrokerageCreationRequest request)
        {
            await _upsertCarePackageBrokerageUseCase.ExecuteAsync(packageId, request.ToDomain());

            return(Ok());
        }
コード例 #5
0
 public static CarePackageBrokerageDomain ToDomain(this CarePackageBrokerageCreationRequest input)
 {
     return(_mapper.Map <CarePackageBrokerageDomain>(input));
 }