public ActionResult VisualizarEmprestimosPorPeriodo(EmprestimoPesquisa emprestimoPesquisa) { List <Emprestimo> emprestimos = new List <Emprestimo>(); try { if (emprestimoPesquisa.DataFim < emprestimoPesquisa.DataInicio) { ModelState.AddModelError("DataFim", "A data final nao pode ser maior que a data inicial."); } if (ModelState.IsValid) { IEmprestimoProcesso processo = EmprestimoProcesso.Instance; emprestimos = processo.ConsultarEmprestimosPorPeriodo(emprestimoPesquisa.DataInicio, emprestimoPesquisa.DataFim); ViewData["emprestimos"] = emprestimos; ViewData.Model = emprestimoPesquisa; return(View(emprestimoPesquisa)); } else { ViewData["emprestimos"] = emprestimos; return(View(emprestimoPesquisa)); } } catch (Exception e) { ViewData["emprestimos"] = emprestimos; return(View(emprestimoPesquisa)); } }
public ActionResult VisualizarEmprestimosPorPeriodo() { if (ClasseAuxiliar.UsuarioLogado == null || (ClasseAuxiliar.DataSelecionada == default(DateTime) || ClasseAuxiliar.AreaSelecionada == null)) { return(RedirectToAction("Index", "Home")); } IEmprestimoProcesso processo = EmprestimoProcesso.Instance; List <Emprestimo> emprestimos = processo.Consultar(); EmprestimoPesquisa emprestimoPesquisa = new EmprestimoPesquisa(); emprestimoPesquisa.DataInicio = DateTime.Now; emprestimoPesquisa.DataFim = DateTime.Now; ViewData["emprestimos"] = emprestimos; return(View(emprestimoPesquisa)); }