示例#1
0
        public async Task <UpdateJobStatusOutcome?> UpdateJobStatusToNewAsync(int jobId, int createdByUserId)
        {
            var request = new PutUpdateJobStatusToNewRequest()
            {
                JobID           = jobId,
                CreatedByUserID = createdByUserId
            };

            var response = await PutAsync <BaseRequestHelpResponse <PutUpdateJobStatusToNewResponse> >($"/api/PutUpdateJobStatusToNew", request);

            if (response.HasContent && response.IsSuccessful)
            {
                return(response.Content.Outcome);
            }
            return(null);
        }
示例#2
0
        public async Task WhenUnSuccessfullyChangingJobStatusToNew_ReturnsFalse()
        {
            _updateJobStatusOutcome = UpdateJobStatusOutcome.BadRequest;
            _request = new PutUpdateJobStatusToNewRequest
            {
                CreatedByUserID = 1,
                JobID           = 1
            };
            _isSameAsProposed = false;
            var response = await _classUnderTest.Handle(_request, CancellationToken.None);

            _repository.Verify(x => x.JobHasStatus(It.IsAny <int>(), It.IsAny <JobStatuses>()), Times.Once);
            _repository.Verify(x => x.UpdateJobStatusNewAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>()), Times.Once);
            _communicationService.Verify(x => x.RequestCommunication(It.IsAny <RequestCommunicationRequest>(), It.IsAny <CancellationToken>()), Times.Never);
            Assert.AreEqual(UpdateJobStatusOutcome.BadRequest, response.Outcome);
        }
示例#3
0
        public async Task WhenVolunteerDoesNotHavePermission_ReturnsUnauthorised()
        {
            _updateJobStatusOutcome = UpdateJobStatusOutcome.Unauthorized;
            _hasPermission          = false;
            _isSameAsProposed       = false;
            _request = new PutUpdateJobStatusToNewRequest
            {
                CreatedByUserID = 1,
                JobID           = 1
            };
            var response = await _classUnderTest.Handle(_request, CancellationToken.None);

            _repository.Verify(x => x.JobHasStatus(It.IsAny <int>(), It.IsAny <JobStatuses>()), Times.Once);
            _repository.Verify(x => x.UpdateJobStatusNewAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>()), Times.Never);
            _communicationService.Verify(x => x.RequestCommunication(It.IsAny <RequestCommunicationRequest>(), It.IsAny <CancellationToken>()), Times.Never);
            Assert.AreEqual(UpdateJobStatusOutcome.Unauthorized, response.Outcome);
        }
示例#4
0
        public async Task WhenJobStatusIsAlreadyOpen_ReturnsAlreadyInThisStatus()
        {
            _updateJobStatusOutcome = UpdateJobStatusOutcome.AlreadyInThisStatus;
            _hasPermission          = true;
            _isSameAsProposed       = true;
            _request = new PutUpdateJobStatusToNewRequest
            {
                CreatedByUserID = 1,
                JobID           = 1
            };
            var response = await _classUnderTest.Handle(_request, CancellationToken.None);

            _repository.Verify(x => x.JobHasStatus(It.IsAny <int>(), It.IsAny <JobStatuses>()), Times.Once);
            _repository.Verify(x => x.UpdateJobStatusNewAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>()), Times.Never);
            _communicationService.Verify(x => x.RequestCommunication(It.IsAny <RequestCommunicationRequest>(), It.IsAny <CancellationToken>()), Times.Never);
            Assert.AreEqual(UpdateJobStatusOutcome.AlreadyInThisStatus, response.Outcome);
        }
示例#5
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "put", Route = null)]
            [RequestBodyType(typeof(PutUpdateJobStatusToNewRequest), "put update job status to open request")] PutUpdateJobStatusToNewRequest req,
            CancellationToken cancellationToken)
        {
            try
            {
                _logger.LogInformation("PutUpdateJobStatusToNew started");
                PutUpdateJobStatusToNewResponse response = await _mediator.Send(req, cancellationToken);

                return(new OkObjectResult(ResponseWrapper <PutUpdateJobStatusToNewResponse, RequestServiceErrorCode> .CreateSuccessfulResponse(response)));
            }
            catch (Exception exc)
            {
                _logger.LogErrorAndNotifyNewRelic("Exception occured in PutUpdateJobStatusToNew", exc);
                return(new ObjectResult(ResponseWrapper <PutUpdateJobStatusToNewResponse, RequestServiceErrorCode> .CreateUnsuccessfulResponse(RequestServiceErrorCode.InternalServerError, "Internal Error"))
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }