public ActionResult SolicitacoesList(Boolean json = false)
        {
            var solicitacoes = db.Solicitacoes
                .Include("Avaliacao")
                .Include("User");

            //Inicializar ViewModel a partir dos modelos de dados
            List<SolicitacaoIndexModel> model = new List<SolicitacaoIndexModel>();
            foreach (var s in solicitacoes)
            {
                SolicitacaoIndexModel modelItem = new SolicitacaoIndexModel();
                modelItem.InjectFrom(s.Avaliacao, s);
                modelItem.InsertFrom(s);
                modelItem.Cancelavel = s.IsCancelavel();
                model.Add(modelItem);
            }
            if (!json)
            {
                return View(model);
            }
            else
            {
                return Json(model, JsonRequestBehavior.AllowGet);
            }
        }
 public void SolicitacaoIndexModelConstructorTest()
 {
     SolicitacaoIndexModel target = new SolicitacaoIndexModel(solicitacao);
     Assert.AreEqual(solicitacao.Ano, target.Ano);
     Assert.AreEqual(solicitacao.AnoSeq, target.AnoSeq);
     Assert.AreEqual(solicitacao.UserName, target.UserName);
 }
 public void InsertFromTest()
 {
     SolicitacaoIndexModel target = new SolicitacaoIndexModel();
     target.InsertFrom(solicitacao);
     Assert.AreEqual(solicitacao.User.FullName, target.UserFullName);
     Assert.AreEqual(target.Ano, solicitacao.Ano);
     Assert.AreEqual(target.Cancelavel, solicitacao.IsCancelavel());
 }
        public ActionResult Index()
        {
            var solicitacoes = from s in db.Solicitacoes
                               join a in db.Avaliacoes on s.Id equals a.Solicitacao.Id
                               where s.User.UserName == User.Identity.Name
                               select new { Solicitacao = s, Avaliacao = a };

            //Inicializar ViewModel a partir dos modelos de dados
            List<SolicitacaoIndexModel> model = new List<SolicitacaoIndexModel>();
            foreach (var line in solicitacoes)
            {
                SolicitacaoIndexModel modelItem = new SolicitacaoIndexModel();
                modelItem.InjectFrom(line.Avaliacao, line.Solicitacao);
                model.Add(modelItem);
            }

            ViewBag.PodeCriarSolicitacao = BusinessLogic.SolicitacaoBL.PodeCriarSolicitacao(User.Identity.Name) == StatusCriacaoSolicitacao.Permitido;

            return View(model);
        }