示例#1
0
        // GET: Emprestimos
        public ActionResult Index()
        {
            var emprestimos = Mapper.Map <IEnumerable <Emprestimo>, IEnumerable <EmprestimoViewModel> >(_wcfServiceClient.GetEmprestimolAll());

            IEnumerable <EmprestimoViewModel> emprestimoViewModels;

            emprestimoViewModels = emprestimos.Select(m => new EmprestimoViewModel
            {
                EmprestimoId           = m.EmprestimoId,
                ClienteNome            = _wcfServiceClient.GetClienteById(m.ClienteId).Nome,
                DataDevolucaoDescricao = m.DataDevolucao != DateTime.MinValue ? m.DataDevolucao.ToString("dd/MM/yyyy") : "-",
                DataDevolverDescricao  = m.DataDevolver.ToString("dd/MM/yyyy"),
                MaterialDescricao      = _wcfServiceClient.GetMaterialById(m.MaterialId).Descricao,
                DevolvidoDescricao     = m.Devolvido ? "Sim" : "Não"
            });

            return(View(emprestimoViewModels));
        }