Example #1
0
 private LicenseData CreateLicenseData(LicenseSM licenseSM)
 {
     return(new LicenseData()
     {
         FirstName = licenseSM.FirstName,
         LastName = licenseSM.LastName,
         Number = licenseSM.Number,
         DateOfBirth = licenseSM.DateOfBirth,
         Expiry = licenseSM.Expiry
     });
 }
Example #2
0
        public async Task <bool> AddLicenseDataToJob(LicenseSM licenseSM, string userId, string appId)
        {
            var currentDocument = await _workQueue.FindByUserId(userId);

            if (currentDocument == null)
            {
                // This is the first thing that a user has uploaded. Create a new work task for them.
                var document = new WorkDocument()
                {
                    UserId      = userId,
                    LicenseData = CreateLicenseData(licenseSM),
                    AppID       = appId
                };

                bool didCreate = await _workQueue.CreateWorkDocumentAsync(document);

                if (!didCreate)
                {
                    _logger.Error("Failed to create new work document using license data.");
                    return(false);
                }

                CheckUploadJobComplete(document);

                // All good, work document created.
                return(true);
            }
            else
            {
                currentDocument.LicenseData = CreateLicenseData(licenseSM);
                bool didCreate = await _workQueue.UpdateWorkDocumentAsync(currentDocument);

                if (!didCreate)
                {
                    _logger.Error("Failed to create new work document using license data.");
                    return(false);
                }

                // All good, work document updated.
                CheckUploadJobComplete(currentDocument);
                return(true);
            }
        }