public async Task <ActionResult> AddFace()
        {
            var id       = Request["id"];
            var personId = Guid.Parse(Request["personId"]);

            try
            {
                await FaceClient.AddPersonFaceAsync(id, personId, Request.Files[0].InputStream);
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View());
            }

            return(RedirectToAction("Index", new { id = id }));
        }
Esempio n. 2
0
        public async Task <ActionResult> AddFace()
        {
            var id       = Request["id"];
            var personId = Guid.Parse(Request["personId"]);

            if (Request.Files.Count > 0)
            {
                //ResizeImage(Request.Files[0].InputStream, ImageToProcess);
                Image  img = Image.FromStream(Request.Files[0].InputStream);
                string url = Request.Url.Authority;
                img.Save(Server.MapPath("~/images") + "\\IDCard\\" + Request["personName"] + ".png", ImageFormat.Png);
            }


            try
            {
                //await FaceClient.AddPersonFaceAsync(id, personId, Request.Files[0].InputStream);
                await RunOperationOnImage(async stream =>
                {
                    await FaceClient.AddPersonFaceAsync(id, personId, stream);
                });
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View());
            }

            //try
            //{
            //    await FaceClient.AddPersonFaceAsync(id, personId, Request.Files[0].InputStream);
            //}
            //catch (Exception ex)
            //{
            //    ViewBag.Error = ex.StackTrace;
            //    return View();
            //}

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