Exemple #1
0
        public Boundary.Response.MashReferral UpdateMashReferral(UpdateMashReferral request, long referralId)
        {
            if (request.UpdateType == "UNASSIGN-WORKER")
            {
                return(_mashReferralGateway.UpdateReferral(request, referralId).ToResponse());
            }

            var worker = request.WorkerId != null?_workerGateway.GetWorkerByWorkerId(request.WorkerId.Value) : _databaseGateway.GetWorkerByEmail(request.WorkerEmail)?.ToDomain(false);

            if (worker == null)
            {
                throw new WorkerNotFoundException($"Worker with email \"{request.WorkerEmail}\" not found");
            }

            return(_mashReferralGateway.UpdateReferral(request, referralId).ToResponse());
        }
Exemple #2
0
        public void UpdatingMashReferralThrowsMashReferralNotFoundExceptionWhenGetInfrastructureUsingIdReturnsNull()
        {
            var mashReferralId = _faker.Random.Long(100);
            var request        = TestHelpers.CreateUpdateMashReferral();

            Action act = () => _mashReferralGateway.UpdateReferral(request, mashReferralId);

            act.Should().Throw <MashReferralNotFoundException>()
            .WithMessage($"MASH referral with id {mashReferralId} not found");
        }