コード例 #1
0
        private async Task <IList <VerificationCandidate> > VerifyFromBytes(byte[] file)
        {
            var result = await _faceProvider.IdentifyFaceAsync(file);

            var hasCandidates = result.Where(x => x.Candidates.Length > 0);
            var candidates    = hasCandidates.SelectMany(y => y.Candidates).Select(c => new VerificationCandidate()
            {
                Confidence = c.Confidence, PersonGroupPersonId = c.PersonId
            }).ToList();
            var model = new List <VerificationCandidate>();

            foreach (var candidate in candidates)
            {
                var employee = await _repo.GetEmployeeByPersonGroupPersonId(candidate.PersonGroupPersonId);

                candidate.Employee = employee;
                if (candidate.Employee.PhotoPath != null)
                {
                    // todo: should probably get rid of one of these
                    var sas = _blobProvider.GetReadSasForBlob(employee.PhotoPath);
                    candidate.CandidateEmployeePhotoUri = sas;
                    candidate.Employee.PhotoPathSas     = sas;
                }

                model.Add(candidate);
            }
            return(model);
        }