public ActionResult Edit(tblLibros libros, int id) { db.Entry(libros).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(tblLibros libros, int id) { var datos = db.tblLibros.Where(a => a.idlibros.Equals(id)).FirstOrDefault(); db.tblLibros.Remove(datos); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblLibros tblLibros = db.tblLibros.Find(id); if (tblLibros == null) { return(HttpNotFound()); } return(View(tblLibros)); }
public ActionResult Create([Bind(Include = "idlibros,fecha,correlativo,instrumento,folios,libro,img,word,idotorgante,idfavorde,id_Personal")] tblLibros tblLibros) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; HttpPostedFileBase file2 = Request.Files[1]; if (file.ContentLength > 0) { var img = (file.FileName).ToLower(); tblLibros.img = "/Content/Libros/" + img; file.SaveAs(Server.MapPath("~/Content/Libros/") + img); } if (file2.ContentLength > 0) { var doc = (file2.FileName).ToLower(); tblLibros.word = "/Content/Libros/" + doc; file2.SaveAs(Server.MapPath("~/Content/Libros/") + doc); } db.tblLibros.Add(tblLibros); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Libros"; notificacion.Message = string.Format("Registro un nuevo libro"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); } } ViewBag.idfavorde = new SelectList(db.tblAfavorde, "idfavorde", "nombres", tblLibros.idfavorde); ViewBag.idotorgante = new SelectList(db.tblOtorgante, "idotorgante", "nombres", tblLibros.idotorgante); ViewBag.id_Personal = new SelectList(db.tblPersonal, "Id_Personal", "Nombres", tblLibros.id_Personal); return(View(tblLibros)); }
public ActionResult Create(tblLibros libros) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; if (file.ContentLength > 0) { var img = (file.FileName).ToLower(); libros.img = "/Content/Libros/" + img; file.SaveAs(Server.MapPath("~/Content/Libros/") + img); } db.tblLibros.Add(libros); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(libros)); }
public ActionResult DeleteConfirmed(int id) { tblLibros tblLibros = db.tblLibros.Find(id); db.tblLibros.Remove(tblLibros); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Libros"; notificacion.Message = string.Format("Elimino un libro"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblLibros tblLibros = db.tblLibros.Find(id); if (tblLibros == null) { return(HttpNotFound()); } ViewBag.idfavorde = new SelectList(db.tblAfavorde.Join( db.tblLibros, a => a.idfavorde, b => b.idlibros, (v, s) => new { v = v, s = s } ) .Select( temp0 => new { v = temp0.v, s = temp0.s } ).Select(m => new SelectListItem { Value = SqlFunctions.StringConvert((double)m.s.idlibros).Trim(), Text = m.v.nombres + " " + m.v.apellidos }), "Value", "Text", 0); ViewBag.idotorgante = new SelectList(db.tblOtorgante.Join( db.tblLibros, a => a.idotorgante, b => b.idlibros, (v, s) => new { v = v, s = s } ) .Select( temp0 => new { v = temp0.v, s = temp0.s } ).Select(m => new SelectListItem { Value = SqlFunctions.StringConvert((double)m.s.idlibros).Trim(), Text = m.v.nombres + " " + m.v.apellidos }), "Value", "Text", 0); ViewBag.personalNotario = (from p in db.tblPersonal join c in db.tblCategoriaPersonal on p.id_CategoriaPersonal equals c.id_CategoriaPersonal where c.CategoriaPersonal == "Notario" //where c.CategoriaPersonal == "Notario" select p).ToList(); return(View(tblLibros)); }