Пример #1
0
        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 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());
        }