private List <Aviso> GerarAvisosDeAluguel() { try { List <Aviso> avisos = new List <Aviso>(); List <Aluguel> alugueis = AluguelService.ObterAlugueisOrdPorId().Where(a => a.EstadoDoAluguel == EstadosAluguel.VENCIDO || a.EstadoDoPagamento == EstadosDePagamento.VENCIDO).ToList(); if (alugueis != null) { foreach (Aluguel a in alugueis) { Aviso aviso = new Aviso(); aviso.Tipo = TiposDeAviso.ALUGUEL_IRREGULAR; if (a.EstadoDoAluguel == EstadosAluguel.VENCIDO) { aviso.Mensagem = "O Aluguel de ID: " + a.AluguelId + ", expirou"; } if (a.EstadoDoPagamento == EstadosDePagamento.VENCIDO) { aviso.Mensagem = "O Aluguel de ID: " + a.AluguelId + ", está com o pagamento vencido"; } aviso.idObjeto = a.AluguelId; avisos.Add(aviso); } } return(avisos); } catch (Exception ex) { throw ex; } }
public ActionResult Index() { string email = HttpContext.GetOwinContext().Authentication.User.Identity.Name; long? id = (long?)long.Parse(Gerenciador.FindByEmail(email).Id); IEnumerable <Aluguel> alugueis = AluguelService.ObterAlugueisOrdPorId().Where(a => a.ClienteId == id).ToList(); AluguelViewModel aluguelView = new AluguelViewModel() { Alugueis = alugueis }; return(View(aluguelView)); }