public ActionResult Create([Bind(Include = "Id_Historial,Id_Caso,Fecha_Inicio,Fecha_Final,Descripcion,Archivo,Fecha_Agregado")] tblHistorial tblHistorial)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];
                    if (file.ContentLength > 0)
                    {
                        var img = (file.FileName).ToLower();
                        tblHistorial.Archivo = "/Content/Historial/" + img;
                        file.SaveAs(Server.MapPath("~/Content/Historial/") + img);
                    }
                    db.tblHistorial.Add(tblHistorial);
                    db.SaveChanges();
                    /*NOTIFICACION*/
                    ApplicationDbContext dbs          = new ApplicationDbContext();
                    Notifications        notificacion = new Notifications();
                    notificacion.Module     = "Historial";
                    notificacion.Message    = string.Format("Registro un nuevo historial");
                    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.Id_Caso = new SelectList(db.tblCasos, "Id_Caso", "Numero_Caso", tblHistorial.Id_Caso);
            return(View(tblHistorial));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblHistorial tblHistorial = db.tblHistorial.Find(id);

            if (tblHistorial == null)
            {
                return(HttpNotFound());
            }
            return(View(tblHistorial));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblHistorial tblHistorial = db.tblHistorial.Find(id);

            if (tblHistorial == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id_Caso = new SelectList(db.tblCasos, "Id_Caso", "Numero_Caso", tblHistorial.Id_Caso);
            return(View(tblHistorial));
        }
        public ActionResult Edit([Bind(Include = "Id_Historial,Id_Caso,Fecha_Inicio,Fecha_Final,Descripcion,Archivo,Fecha_Agregado")] tblHistorial tblHistorial)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];
                    if (file.ContentLength > 0)
                    {
                        var img = (file.FileName).ToLower();
                        tblHistorial.Archivo = "/Content/Historial/" + img;
                        file.SaveAs(Server.MapPath("~/Content/Historial/") + img);
                    }
                    var queryarchivo = (from x in db.tblHistorial
                                        where x.Id_Historial == tblHistorial.Id_Historial
                                        select x.Archivo).First();

                    if (file.ContentLength == 0)
                    {
                        //var query = (from x in db.tblLibros
                        //             where x.idlibros == tblLibros.idlibros
                        //             select x.word).First();
                        //tblLibros.img = query.img;
                        tblHistorial.Archivo = queryarchivo;
                    }
                }
                db.Entry(tblHistorial).State = EntityState.Modified;
                db.SaveChanges();

                /*NOTIFICACION*/
                ApplicationDbContext dbs          = new ApplicationDbContext();
                Notifications        notificacion = new Notifications();
                notificacion.Module     = "Historial";
                notificacion.Message    = string.Format("Edito un historial");
                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.Id_Caso = new SelectList(db.tblCasos, "Id_Caso", "Numero_Caso", tblHistorial.Id_Caso);
            return(View(tblHistorial));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            tblHistorial tblHistorial = db.tblHistorial.Find(id);

            db.tblHistorial.Remove(tblHistorial);
            db.SaveChanges();
            /*NOTIFICACION*/
            ApplicationDbContext dbs          = new ApplicationDbContext();
            Notifications        notificacion = new Notifications();

            notificacion.Module     = "Historial";
            notificacion.Message    = string.Format("Elimino un historial");
            notificacion.Date       = DateTime.Now;
            notificacion.Viewed     = false;
            notificacion.Usuario_Id = User.Identity.GetUserId();

            dbs.Notification.Add(notificacion);
            dbs.SaveChanges();
            /*FIN NOTIFICACION*/
            return(RedirectToAction("Index"));
        }