public ActionResult Index() { var ultimosEmprestimos = EmprestimoBusiness.ListarUltimosEmprestimos(10, User.Identity.Name); var ultimoEmprestimosVm = Mapper.Map <List <EmprestimoViewModel> >(ultimosEmprestimos); return(View(ultimoEmprestimosVm)); }
private void CriaViewBagDropdownJogosDisponiveis() { var jogosDisponiveis = EmprestimoBusiness.ConsultarJogosDisponiveis(User.Identity.Name); var jogosDisponiveisVm = Mapper.Map <List <JogoViewModel> >(jogosDisponiveis); ViewBag.DropDownJogos = new SelectList(jogosDisponiveisVm, "JogoId", "Nome"); }
private void CarregarGrid() { EmprestimoBusiness business = new EmprestimoBusiness(); List <vw_emprestimo_aluno> emprestimo = business.ListarEmprestimosAlunos(txtTitulo.Text.Trim(), txtAluno.Text.Trim(), chkDevolvido.Checked); dgvEmprestimo.AutoGenerateColumns = false; dgvEmprestimo.DataSource = emprestimo; }
public IActionResult Salvar(CadastroEmprestimoModel model) { Emprestimo entidade = new Emprestimo(); entidade.Amigo = model.Amigo; entidade.Jogo = model.Jogo; entidade.DataEmprestimo = DateTime.Today; entidade = new EmprestimoBusiness(this._configuration).SalvarOuAtualizar(entidade); return(RedirectToAction(nameof(HomeController.Index), "Home")); }
private void Emprestimo() { tb_emprestimo emprestimo = new tb_emprestimo(); emprestimo.bt_devolvido = false; emprestimo.dt_emprestimo = DateTime.Now; emprestimo.nm_funcionario = txtFuncionario.Text; emprestimo.dt_devolucao = Convert.ToDateTime(dtpDevolucao.Text); emprestimo.tb_livro_id_livro = Convert.ToInt32(cboLivro.SelectedValue); EmprestimoBusiness emprestimos = new EmprestimoBusiness(); emprestimos.CadastroNovoEmprestimo(emprestimo, txtRA.Text, txtEmail.Text); }
private void CriaViewBagDropdownAmigos(params int[] idAmigoSelecionado) { var amigos = EmprestimoBusiness.ConsultarAmigos(User.Identity.Name); var amigosVm = Mapper.Map <List <AmigoViewModel> >(amigos); if (idAmigoSelecionado.Any()) { ViewBag.DropDownAmigos = new SelectList(amigosVm, "AmigoId", "Nome", idAmigoSelecionado[0]); } else { ViewBag.DropDownAmigos = new SelectList(amigosVm, "AmigoId", "Nome"); } }
public ActionResult Create([Bind(Include = "AmigoId,JogoId,DataEmprestimo,DataDevolucao")] EmprestimoViewModel emprestimoVm) { if (ModelState.IsValid && DataDevolucaoValidas(emprestimoVm)) { var usuario = UsuarioBusiness.ConsultaUsuario(User.Identity.Name); var emprestimo = Mapper.Map <Emprestimo>(emprestimoVm); emprestimo.UsuarioId = usuario.UsuarioId; EmprestimoBusiness.Salvar(emprestimo); return(RedirectToAction("Index")); } CriaViewBagDropdownAmigos(); CriaViewBagDropdownJogosDisponiveis(); return(View(emprestimoVm)); }
// GET: Emprestimoes/Delete/5 public ActionResult Delete(int?idAmigo, int?idJogo) { if (idAmigo == null || idJogo == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var emprestimo = EmprestimoBusiness.ConsultarEmprestimoEspecifico(idAmigo.Value, idJogo.Value, User.Identity.Name); if (emprestimo == null) { return(HttpNotFound()); } var emprestimoVm = Mapper.Map <EmprestimoViewModel>(emprestimo); return(View(emprestimoVm)); }
public ActionResult Edit(EmprestimoViewModel emprestimoVm) { if (ModelState.IsValid && DataDevolucaoValidas(emprestimoVm)) { EmprestimoBusiness.ExcluirPorId(emprestimoVm.AmigoId, emprestimoVm.JogoIdAntigo, User.Identity.Name); var usuario = UsuarioBusiness.ConsultaUsuario(User.Identity.Name); var emprestimo = Mapper.Map <Emprestimo>(emprestimoVm); emprestimo.UsuarioId = usuario.UsuarioId; EmprestimoBusiness.Salvar(emprestimo); return(RedirectToAction("Index")); } CriaViewBagDropdownAmigos(emprestimoVm.AmigoId); var jogo = JogoBusiness.ConsultarPorId(emprestimoVm.JogoIdAntigo); CriaViewBagDropdownJogosDisponiveisEdicao(jogo); return(View(emprestimoVm)); }
private void AlterarEmprestimo() { tb_emprestimo emprestimo = new tb_emprestimo(); emprestimo.bt_devolvido = chkDevolvido.Checked; emprestimo.nm_funcionario = txtFuncionario.Text; emprestimo.dt_devolucao = Convert.ToDateTime(dtpDevolucao.Text); emprestimo.tb_livro_id_livro = Convert.ToInt32(cboLivro.SelectedValue); emprestimo.dt_emprestimo = Convert.ToDateTime(dtpEmprestimo.Text); tb_aluno_dados dados = new tb_aluno_dados(); dados.ds_email = txtEmail.Text; dados.id_aluno_dados = idAluno; EmprestimoBusiness emprestimos = new EmprestimoBusiness(); emprestimos.AlterarEmprestimo(emprestimo, id, dados); }
private void btnRemover_Click(object sender, EventArgs e) { try { vw_emprestimo_aluno locatario = dgvEmprestimo.CurrentRow.DataBoundItem as vw_emprestimo_aluno; EmprestimoBusiness business = new EmprestimoBusiness(); business.RemoverEmprestimo(locatario.id_emprestimo); MessageBox.Show("Emprestimo removido com sucesso!", "Biblioteca", MessageBoxButtons.OK, MessageBoxIcon.Information); CarregarGrid(); } catch (Exception ex) { if (ex.Message.Contains("Referência de objeto não definida para uma instância de um objeto")) { MessageBox.Show("Selecione um emprestimo!", "Biblioteca", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void Emprestimo() { tb_emprestimo emprestimo = new tb_emprestimo(); emprestimo.bt_devolvido = false; emprestimo.dt_emprestimo = DateTime.Now; emprestimo.nm_funcionario = txtFuncionario.Text; emprestimo.dt_devolucao = Convert.ToDateTime(dtpDevolucao.Text); emprestimo.tb_livro_id_livro = Convert.ToInt32(cboLivro.SelectedValue); tb_locatario prof = new tb_locatario(); prof.nm_locatario = txtNome.Text; prof.nu_celular = txtCelular.Text; prof.nu_cpf = txtCPF.Text; prof.ds_email = txtEmail.Text; EmprestimoBusiness emprestimos = new EmprestimoBusiness(); cad = emprestimos.CadastroNovoEmprestimo(emprestimo, prof); }
private void AlterarEmprestimo() { tb_emprestimo emprestimo = new tb_emprestimo(); emprestimo.bt_devolvido = chkDevolvido.Checked; emprestimo.nm_funcionario = txtFuncionario.Text; emprestimo.dt_devolucao = Convert.ToDateTime(dtpDevolucao.Text); emprestimo.tb_livro_id_livro = Convert.ToInt32(cboLivro.SelectedValue); emprestimo.dt_emprestimo = Convert.ToDateTime(dtpEmprestimo.Text); tb_locatario prof = new tb_locatario(); prof.nm_locatario = txtNome.Text; prof.nu_celular = txtCelular.Text; prof.nu_cpf = txtCPF.Text; prof.ds_email = txtEmail.Text; EmprestimoBusiness emprestimos = new EmprestimoBusiness(); emprestimos.AlterarEmprestimo(emprestimo, id, prof); }
// GET: Emprestimoes/Edit/5 public ActionResult Edit(int?idAmigo, int?idJogo) { if (idAmigo == null || idJogo == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var emprestimo = EmprestimoBusiness.ConsultarEmprestimoEspecifico(idAmigo.Value, idJogo.Value, User.Identity.Name); if (emprestimo == null) { return(HttpNotFound()); } var emprestimoVm = Mapper.Map <EmprestimoViewModel>(emprestimo); emprestimoVm.JogoIdAntigo = emprestimo.JogoId; CriaViewBagDropdownAmigos(emprestimoVm.AmigoId); CriaViewBagDropdownJogosDisponiveisEdicao(emprestimo.Jogo); return(View(emprestimoVm)); }
public ActionResult DeleteConfirmed(int idAmigo, int idJogo) { EmprestimoBusiness.ExcluirPorId(idAmigo, idJogo, User.Identity.Name); return(RedirectToAction("Index")); }