Пример #1
0
        public async Task <bool> AddPassportDataToJob(PassportSM passportSM, 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,
                    PassportData = CreatePassportData(passportSM),
                    AppID        = appId
                };

                bool didCreate = await _workQueue.CreateWorkDocumentAsync(document);

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

                CheckUploadJobComplete(document);
                // All good, work document created.
                return(true);
            }
            else
            {
                currentDocument.PassportData = CreatePassportData(passportSM);
                bool didCreate = await _workQueue.UpdateWorkDocumentAsync(currentDocument);

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

                // All good, work document created.
                CheckUploadJobComplete(currentDocument);
                return(true);
            }
        }
        public async Task <ServiceResult> CreateFinalJob(string userId)
        {
            // Okay, get the user from the database and also get the mongo work document.
            // Create a job in a new database table called FinalJob. When this is created, we can then push it to the database. Then, the mvc can request a list of jobs. Each with information about the Job.
            // The way to handle the images.. we can get download links for each of them for 10 minutes..pass that in the
            // Job JSON then display this in the MVC?

            try
            {
                WorkDocument document = await workQueue.FindByUserId(userId);

                var user = Db.Users.Find(int.Parse(userId));;
                user.Status = Dependency.Enums.UserStatus.Pending;

                JobDM dm = new JobDM()
                {
                    UserId             = userId,
                    ClaimedFirstName   = user.FirstName,
                    ClaimedLastName    = user.LastName,
                    FirstNameLicense   = document.LicenseData.FirstName,
                    LastNameLicense    = document.LicenseData.LastName,
                    LicenseNumber      = document.LicenseData.Number,
                    LicenseDateOfBirth = document.LicenseData.DateOfBirth,
                    LicenseExpiry      = document.LicenseData.Expiry,
                    FirstNamePassport  = document.PassportData.FirstName,
                    LastNamePassport   = document.PassportData.LastName,
                    PassportNumber     = document.PassportData.Number,
                    PassportExpiry     = document.PassportData.Expiry,
                    MRZ = document.PassportData.MRZ,
                    PassportDateOfBirth = document.PassportData.DateOfBirth,
                    AppId   = user.AppID,
                    Created = DateTime.Now
                };

                Db.Jobs.Add(dm);
                await Db.SaveChangesAsync();
            }
            catch (Exception e)
            {
                Logger.Error(e.ToString());
                ServiceResult.Errors.Add("Error creating the final job.");
            }

            return(ServiceResult);
        }