Esempio n. 1
0
        public async Task ShouldCreateDraftPayRun(PayrunType type)
        {
            ClearDatabase();
            var payRunCreationRequest = new DraftPayRunCreationRequest
            {
                Type         = type,
                PaidFromDate = _periodFrom,
                PaidUpToDate = _periodTo
            };
            var url      = $"api/v1/payruns";
            var response = await _fixture.RestClient.PostAsync <object>(url, payRunCreationRequest);

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

            var payRuns = _fixture.DatabaseContext.Payruns.ToList();

            payRuns.Should().HaveCount(1);
            payRuns.First().Status.Should().Be(PayrunStatus.Draft);
        }
Esempio n. 2
0
        public async Task ShouldFailIfExistsAnUnApprovedPayRun(PayrunStatus status)
        {
            ClearDatabase();
            _fixture.DatabaseContext.Add(TestDataHelper.CreatePayRun(status: status));
            await _fixture.DatabaseContext.SaveChangesAsync();

            var payRunCreationRequest = new DraftPayRunCreationRequest
            {
                Type         = PayrunType.ResidentialRecurring,
                PaidFromDate = _periodFrom,
                PaidUpToDate = _periodTo
            };
            var url      = $"api/v1/payruns";
            var response = await _fixture.RestClient.PostAsync <object>(url, payRunCreationRequest);

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

            var payRuns = _fixture.DatabaseContext.Payruns.ToList();

            payRuns.Should().HaveCount(1);
        }
 public static DraftPayRunCreationDomain ToDomain(this DraftPayRunCreationRequest input)
 {
     return(_mapper.Map <DraftPayRunCreationDomain>(input));
 }
        public async Task <ActionResult> CreateDraftPayRun(DraftPayRunCreationRequest request)
        {
            await _createDraftPayRunUseCase.CreateDraftPayRun(request.ToDomain());

            return(Ok());
        }