public ActionResult DeleteConfirmed(int id) { FotoPersona fotoPersona = db.fotoPersonas.Find(id); db.fotoPersonas.Remove(fotoPersona); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,idPersona,faceId")] FotoPersona fotoPersona) { if (ModelState.IsValid) { db.Entry(fotoPersona).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fotoPersona)); }
public ActionResult Create([Bind(Include = "id,idPersona,faceId")] FotoPersona fotoPersona) { if (ModelState.IsValid) { db.fotoPersonas.Add(fotoPersona); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fotoPersona)); }
public async Task <ActionResult> Create(Persona persona, HttpPostedFileBase file) { if (ModelState.IsValid) { try { //string fileName = file.FileName; if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Fotos"), fileName); file.SaveAs(path); byte[] img = GetImageAsByteArray(path.ToString()); //byte[] img = GetImageAsByteArray(fileName); string resultado = await UploadUserPictureApiCommand("http://libros.westeurope.cloudapp.azure.com/nuevapersona", "[]", img); //await UploadUserPictureApiCommand("http://libros.westeurope.cloudapp.azure.com/reconpersona", "[]", img); if (resultado.Equals("-1")) { ViewBag.Message = "Seleccione una foto mas clara"; return(View()); } else { db.personas.Add(persona); db.SaveChanges(); FotoPersona fotoPersona = new FotoPersona(); fotoPersona.idPersona = Int32.Parse(persona.Id); fotoPersona.faceId = resultado; db.fotoPersonas.Add(fotoPersona); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.Message = "Seleccione Foto"; return(View()); } } catch (Exception ex) { ViewBag.Message = ex.ToString(); return(View()); } } else { ViewBag.Message = "Modelo Invalido"; return(View()); } }
// GET: FotoPersonas/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FotoPersona fotoPersona = db.fotoPersonas.Find(id); if (fotoPersona == null) { return(HttpNotFound()); } return(View(fotoPersona)); }