public IHttpActionResult PutEmopicture(int id, Emopicture emopicture)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != emopicture.Id)
            {
                return(BadRequest());
            }

            db.Entry(emopicture).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmopictureExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Emopicture emopicture = db.Emopictures.Find(id);

            db.Emopictures.Remove(emopicture);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Name,Path")] Emopicture emopicture)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emopicture).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emopicture));
 }
        public IHttpActionResult GetEmopicture(int id)
        {
            Emopicture emopicture = db.Emopictures.Find(id);

            if (emopicture == null)
            {
                return(NotFound());
            }

            return(Ok(emopicture));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Path")] Emopicture emopicture)
        {
            if (ModelState.IsValid)
            {
                db.Emopictures.Add(emopicture);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(emopicture));
        }
        public async Task <Emopicture> DetectAndExtracfacesAsync(Stream imageStream)
        {
            IEnumerable <FaceAttributeType> faceAttributes = new FaceAttributeType[] { FaceAttributeType.Emotion };

            Face[] faces = await emoClient.DetectAsync(imageStream, false, false, faceAttributes);

            var emoPicture = new Emopicture();

            emoPicture.Faces = ExtractFaces(faces, emoPicture);

            return(emoPicture);
        }
        public IHttpActionResult PostEmopicture(Emopicture emopicture)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Emopictures.Add(emopicture);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = emopicture.Id }, emopicture));
        }
        public IHttpActionResult DeleteEmopicture(int id)
        {
            Emopicture emopicture = db.Emopictures.Find(id);

            if (emopicture == null)
            {
                return(NotFound());
            }

            db.Emopictures.Remove(emopicture);
            db.SaveChanges();

            return(Ok(emopicture));
        }
        // GET: Emopictures/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Emopicture emopicture = db.Emopictures.Find(id);

            if (emopicture == null)
            {
                return(HttpNotFound());
            }
            return(View(emopicture));
        }
示例#10
0
        private ObservableCollection <EmoFace> ExtractFaces(Face[] faces, Emopicture emoPicture)
        {
            var listaFaces = new ObservableCollection <EmoFace>();

            foreach (var face in faces)
            {
                var emoFace = new EmoFace()
                {
                    X       = face.FaceRectangle.Left,
                    Y       = face.FaceRectangle.Top,
                    Width   = face.FaceRectangle.Width,
                    Height  = face.FaceRectangle.Height,
                    Picture = emoPicture
                };
                emoFace.Emotions = ProcessEmotions(face.FaceAttributes.Emotion, emoFace);
                listaFaces.Add(emoFace);
            }

            return(listaFaces);
        }