public ActionResult DeleteConfirmed(int id) { EMPRESTIMO eMPRESTIMO = db.EMPRESTIMO.Find(id); db.EMPRESTIMO.Remove(eMPRESTIMO); GAME objGame = db.GAME.Find(eMPRESTIMO.CODGAME); objGame.TITULOEMPRESTADO = false; db.SaveChanges(); return(RedirectToAction("Index")); }
internal void registrarEmprestimo(EXEMPLAR exemplarDigitando, USUARIO usuarioLogado) { if (permiteEmprestimo(exemplarDigitando, usuarioLogado)) { EMPRESTIMO e = new EMPRESTIMO(); e.fkExemplar = exemplarDigitando.id; e.dtEmprestimo = DateTime.Now.Date; e.dtPrazoDevolucao = e.dtEmprestimo.AddDays(usuarioLogado.PERFIL.diasParaEmprestimo); e.fkUsuario = usuarioLogado.id; persist(e); } }
// GET: EmprestimoGame/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EMPRESTIMO eMPRESTIMO = db.EMPRESTIMO.Find(id); if (eMPRESTIMO == null) { return(HttpNotFound()); } return(View(eMPRESTIMO)); }
private void txtExemplar_TextChanged(object sender, EventArgs e) { int idExemplar = 0; int.TryParse(txtExemplar.Text, out idExemplar); emprestimo = c.getEmprestimo(idExemplar); if (emprestimo != null) { lblExemplar.Text = "Data empréstimo: " + emprestimo.dtEmprestimo.ToShortDateString() + " Livro " + emprestimo.EXEMPLAR.LIVRO.titulo; } else { lblExemplar.Text = String.Empty; } }
public void persist(EMPRESTIMO emprestimo) { using (var db = new bibliotecaEntities()) { if (emprestimo.id != 0) { db.Entry(emprestimo).State = System.Data.Entity.EntityState.Modified; } else { db.EMPRESTIMO.Add(emprestimo); } db.SaveChanges(); } }
internal void devolver(EMPRESTIMO emprestimo) { if (emprestimo == null) { throw new DevolucaoFalhouException("Exemplar não está emprestado"); } emprestimo.dtDevolucao = DateTime.Now.Date; //Se está devolvendo depois do prazo de devolução deve gerar multa if (emprestimo.dtDevolucao > emprestimo.dtPrazoDevolucao) { MULTA m = new MULTA(); m.vencimento = DateTime.Now.AddDays(emprestimo.USUARIO.PERFIL.diasParaEmprestimo); m.valor = emprestimo.USUARIO.PERFIL.valorMulta * (int)(DateTime.Now.Date - emprestimo.dtPrazoDevolucao).TotalDays; Controller.MultaController mc = new Controller.MultaController(); mc.persist(m); emprestimo.fkMulta = m.id; } persist(emprestimo); }
public ActionResult Create([Bind(Include = "CODEMPRESTIMO,CODUSER,CODGAME")] EMPRESTIMO eMPRESTIMO) { if (ModelState.IsValid) { eMPRESTIMO.DATAEMPRESTIMO = DateTime.Now; db.EMPRESTIMO.Add(eMPRESTIMO); GAME objGame = db.GAME.Find(eMPRESTIMO.CODGAME); objGame.TITULOEMPRESTADO = true; db.SaveChanges(); return(RedirectToAction("Index")); } var idUser = User.Identity.GetUserId(); List <AspNetUsers> objUsuario = db.AspNetUsers.Where(c => !c.Id.Equals(idUser)).AsNoTracking().ToList(); ViewBag.CODUSER = new SelectList(objUsuario, "Id", "UserName", eMPRESTIMO.CODUSER); ViewBag.CODPLATAFORMA = new SelectList(db.PLATAFORMA, "CODPLATAFORMA", "DESCRICAO"); ViewBag.CODGAME = new SelectList("", "CODGAME", "DESCRICAO"); return(View(eMPRESTIMO)); }