Example #1
0
        public async Task <bool> Handle(UpdateOrganisationTypeRequest request, CancellationToken cancellationToken)
        {
            ValidateUpdateTypeRequest(request);

            var auditRecord = _auditLogService.AuditOrganisationType(request.OrganisationId, request.UpdatedBy, request.OrganisationTypeId);

            var success = false;

            if (auditRecord.ChangesMade && request.OrganisationTypeId != OrganisationType.Unassigned)
            {
                success = await _updateOrganisationRepository.UpdateOrganisationType(request.OrganisationId,
                                                                                     request.OrganisationTypeId, request.UpdatedBy);
            }
            if (!success)
            {
                return(await Task.FromResult(false));
            }

            return(await _updateOrganisationRepository.WriteFieldChangesToAuditLog(auditRecord));
        }