public ActionResult DeleteConfirmed(int id) { Secreto secreto = db.Secretoes.Find(id); db.Secretoes.Remove(secreto); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,nombre")] Secreto secreto) { if (ModelState.IsValid) { db.Entry(secreto).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(secreto)); }
//borra public async Task BorrarSecreto(Secreto secreto) { try { tareaContext.Secretos.Remove(secreto); await tareaContext.SaveChangesAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
//escribe public async Task <Secreto> AgregarSecreto(Secreto secreto) { try { tareaContext.Secretos.Add(secreto); await tareaContext.SaveChangesAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(secreto); }
// GET: Secreto/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Secreto secreto = db.Secretoes.Find(id); if (secreto == null) { return(HttpNotFound()); } return(View(secreto)); }
//edita public async Task <Secreto> EditarSecreto(Secreto secreto) { try { var SecretoExistete = tareaContext.Secretos.FirstOrDefault(a => a.Id == secreto.Id); if (SecretoExistete != null) { tareaContext.Update(secreto); await tareaContext.SaveChangesAsync(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(secreto); }
public ActionResult CreateSecreto([Bind(Include = "ID,nombre")] Secreto secreto, HttpPostedFileBase upload) { try { db.Secretoes.Add(secreto); db.SaveChanges(); PersonaXSecreto personaSecreto = new PersonaXSecreto(); personaSecreto.id_persona = Int32.Parse(Session["ID"].ToString()); personaSecreto.id_secreto = secreto.ID; db.PersonaXSecretoes.Add(personaSecreto); db.SaveChanges(); if (upload != null) { upload.SaveAs(Path.Combine(Server.MapPath("~/App_Data/uploads"), upload.FileName)); string fullPath = Path.Combine(Server.MapPath("~/App_Data/uploads"), upload.FileName); InsertParticipacionCongresoaDoc(System.Guid.NewGuid(), System.IO.Path.GetFileName(upload.FileName), fullPath, secreto.ID); } ViewBag.secretoAgregado = secreto.nombre; return(View()); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { ViewBag.errorSecreto = "Error: " + dbEx; Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } return(View()); } }