示例#1
0
        public ActionResult Reservar([Bind(Include = "IdReserva,IdUsuario,IdLibro")] reservaLibro reserva, FormCollection form)
        {
            var IdLibroq   = form["IdLibro"];
            var conversion = Int32.Parse(IdLibroq);
            var libroDB    = reserva.IdLibro;
            var tmm        = 2;
            var IdUserq    = form["IdUsuario"];
            var UsuarioDB  = reserva.IdUsuario;

            if (ModelState.IsValid)
            {
                //var usuario = User.Identity.GetUserName(); ;
                //var libro =

                if ((tmm == libroDB) && (IdUserq == UsuarioDB))
                {
                    ViewBag.LibroId1 = conversion;
                    ViewBag.LibroId2 = libroDB;

                    ViewBag.Error = "Lo siento, pero ya ha seleccionado este libro";
                }
                else
                {
                    ViewBag.Error = "Su libro se ha inscrito correctamente";
                    db.reservaActiva.Add(reserva);
                    db.SaveChanges();
                }
                //return RedirectToAction("Index");
            }

            return(View(reserva));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            reservaLibro reservaLibro = db.reservaActiva.Find(id);

            db.reservaActiva.Remove(reservaLibro);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "IdReserva,IdUsuario,IdLibro")] reservaLibro reservaLibro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reservaLibro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdLibro = new SelectList(db.Libros, "IdLibro", "Nombre");
     return(View(reservaLibro));
 }
示例#4
0
 public ActionResult Create([Bind(Include = "IdReserva,IdUsuario,IdLibro")] reservaLibro reservaLibro)
 {
     if (ModelState.IsValid)
     {
         db.reservaActiva.Add(reservaLibro);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdLibro = new SelectList(db.Libros, "IdLibro", "Nombre");
     return(View(reservaLibro));
 }
示例#5
0
        // GET: reservaLibroes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            reservaLibro reservaLibro = db.reservaActiva.Find(id);

            if (reservaLibro == null)
            {
                return(HttpNotFound());
            }
            return(View(reservaLibro));
        }
示例#6
0
        // GET: reservaLibroes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            reservaLibro reservaLibro = db.reservaActiva.Find(id);

            if (reservaLibro == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdLibro = new SelectList(db.Libros, "IdLibro", "Nombre");
            return(View(reservaLibro));
        }