예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ModelEmprestimo modelEmprestimo = db.emprestimo.Find(id);

            db.emprestimo.Remove(modelEmprestimo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
 public ActionResult Edit([Bind(Include = "idEmprestimo,RA,livro_id,qtd,data_emp,data_devol")] ModelEmprestimo modelEmprestimo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(modelEmprestimo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(modelEmprestimo));
 }
예제 #3
0
        public ActionResult Create([Bind(Include = "idEmprestimo,RA,livro_id,qtd,data_emp,data_devol")] ModelEmprestimo modelEmprestimo)
        {
            if (ModelState.IsValid)
            {
                db.emprestimo.Add(modelEmprestimo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(modelEmprestimo));
        }
예제 #4
0
        // GET: ModelEmprestimoes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ModelEmprestimo modelEmprestimo = db.emprestimo.Find(id);

            if (modelEmprestimo == null)
            {
                return(HttpNotFound());
            }
            return(View(modelEmprestimo));
        }
예제 #5
0
        public ActionResult Devolucao(int id)
        {
            var emprestimo = (_emprestimoService.Get() as IQueryable <Emprestimo>).Where(x => x.JogoId == id && x.Ativo == true).FirstOrDefault();

            var amigo = _amigoService.Get(emprestimo.AmigoId);
            var model = new ModelEmprestimo()
            {
                Emprestimo = emprestimo, Amigos = new List <Amigo>()
                {
                    amigo
                }
            };

            //var amigo = _jogoService.Get(id);
            return(View(model));
        }
예제 #6
0
        public ActionResult Emprestimo(int id)
        {
            ViewBag.Message = "Acessar";

            var jogo       = _jogoService.Get(id);
            var emprestimo = new Emprestimo()
            {
                JogoId = id, Jogo = jogo
            };
            var model = new ModelEmprestimo()
            {
                Emprestimo = emprestimo
            };

            model.Amigos = (_amigoService.Get() as IQueryable <Amigo>).ToList();

            return(View(model));
        }
예제 #7
0
        public ActionResult Emprestimo(Emprestimo emprestimo)
        {
            var retorno = _jogoService.Emprestar(emprestimo);

            if (retorno != null)
            {
                return(Redirect("\\Jogos\\Jogos"));
            }
            else
            {
                var jogo = _jogoService.Get(emprestimo.JogoId);
                emprestimo.Jogo = jogo;
                var model = new ModelEmprestimo()
                {
                    Emprestimo = emprestimo,
                };
                model.Amigos = (_amigoService.Get() as IQueryable <Amigo>).ToList();

                ViewBag.Message = EscopoBase._notificacoes;
                return(View(model));
            }
        }