public ActionResult DeleteConfirmed(int id) { CursoLibre cursoLibre = db.CursoLibres.Find(id); db.CursoLibres.Remove(cursoLibre); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,nombre")] CursoLibre cursoLibre) { if (ModelState.IsValid) { db.Entry(cursoLibre).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cursoLibre)); }
// GET: CursoLibre/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CursoLibre cursoLibre = db.CursoLibres.Find(id); if (cursoLibre == null) { return(HttpNotFound()); } return(View(cursoLibre)); }
public ActionResult CreateCursoLibre([Bind(Include = "ID,nombre")] CursoLibre cursoLibre, HttpPostedFileBase upload) { try { db.CursoLibres.Add(cursoLibre); db.SaveChanges(); PersonaXCursoLibre personaCurso = new PersonaXCursoLibre(); personaCurso.id_persona = Int32.Parse(Session["ID"].ToString()); personaCurso.id_curso = cursoLibre.ID; db.PersonaXCursoLibres.Add(personaCurso); 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); InsertCursoDoc(System.Guid.NewGuid(), System.IO.Path.GetFileName(upload.FileName), fullPath, cursoLibre.ID); } ViewBag.libreAgregado = cursoLibre.nombre; return(View()); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { ViewBag.errorLibre = "Error: " + dbEx; Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } return(View()); } }