예제 #1
0
        public async Task <Guid> CreateProfile(FaceVerificationProfile model)
        {
            var groupId = Configuration["PersonGroupId"];

            var url = Configuration["CognitiveFacesUri"] + $"/persongroups/{groupId}/persons";

            var key = Configuration["CognitiveFacesKey"];

            var payload = "{ \"name\": \"" + model.Name + "\"}";

            var byteData = Encoding.UTF8.GetBytes(payload);

            using (var content = new ByteArrayContent(byteData))
            {
                var response = await CognitiveServicesHttpClient.HttpPost(content, url, key);

                var responseBytes = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    var result = JSONHelper.FromJson <CreatePersonResponse>(responseBytes);

                    return(result.PersonId);
                }

                throw new Exception($"Failed request : {responseBytes} ");
            }
        }
        public async Task <ActionResult> CreateProfile(FaceVerificationProfile model)
        {
            if (ModelState.IsValid)
            {
                var profileId = await FaceVerificationService.CreateProfile(model);

                return(RedirectToAction("EnrollProfile", new { id = profileId }));
            }

            return(View(model));
        }
        public IActionResult CreateProfile()
        {
            var model = new FaceVerificationProfile();

            return(View(model));
        }