1
I am trying to display the result of my query in the view. However the value DESC_DESC_ORIGEM is empty.
Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using System.Data.Entity;
using System.Net;
using ControleTTM.EntityFramework;
using ControleTTM.Models;
using ControleTTM.Helper;
using ControleTTM.ViewModel;
using ControleTTM.Filters;
namespace ControleTTM.Controllers
{
[MyFirstCustomFilter]
public class ChamadoController : Controller
{
private ModelCTTM db = new ModelCTTM();
// GET: Chamado
public ActionResult Index()
{
var resultado = (from a in db.NEW_CTTM_TICKETS_OPEN
join b in db.NEW_CTTM_ORIGIN_PRIORITY
on a.ID_ORIGIN equals b.ID_ORIGIN
select new
{
CTTM_CHAMADO_ID = a.CTTM_CHAMADO_ID,
SYSTEM_STATUS_ID = a.SYSTEM_STATUS_ID,
ID_SISTEMA_ORIGEM = a.ID_SISTEMA_ORIGEM,
CODIGO = a.CODIGO,
IDADE = a.IDADE,
IDADE_CASO = a.IDADE_CASO,
TELEFONE_PRINCIPAL = a.TELEFONE_PRINCIPAL,
ID_ORIGIN = a.ID_ORIGIN,
DT_CRIACAO = a.DT_CRIACAO,
STATUS = a.STATUS,
SEVERIDADE = a.SEVERIDADE,
RAZAO_SOCIAL = a.RAZAO_SOCIAL,
SEGMENTO = a.SEGMENTO,
ORGANIZACAO = a.ORGANIZACAO,
ID_TITLE = a.ID_TITLE,
PLANO = a.PLANO,
TELEFONE_ALTERNATIVO = a.TELEFONE_ALTERNATIVO,
CPF = a.CPF,
CNPJ = a.CNPJ,
HISTORICO = a.HISTORICO,
NOTAS = a.NOTAS,
NE_ID = a.NE_ID,
ORIGIN_LEVEL = a.ORIGIN_LEVEL,
ID_SLA = a.ID_SLA,
SLA_LEVEL = a.SLA_LEVEL,
ID_TYPE = a.ID_TYPE,
PENDING = a.PENDING,
FG_TRATAMENTO = a.FG_TRATAMENTO,
DESC_ORIGEM = b.DESC_ORIGIN
}).ToList();
return View(resultado);
}
}
}
MODEL
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
using ControleTTM.EMPresets;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;
using ControleTTM.EntityFramework;
namespace ControleTTM.Models
{
public class Chamado
{
public string CN { get; set; }
public string GSM { get; set; }
public virtual string DESC_ORIGEM { get; set; }
public EntityFramework.ModelCTTM model { get; set; }
//public virtual EntityFramework.NEW_CTTM_ORIGIN_PRIORITY NEW_CTTM_ORIGIN_PRIORITYS { get; set; }
public virtual ICollection<EntityFramework.NEW_CTTM_ORIGIN_PRIORITY> NEW_CTTM_ORIGIN_PRIORITYS { get; set; }
public string CTTM_CHAMADO_ID { get; set; }
public string SYSTEM_STATUS_ID { get; set; }
public string ID_SISTEMA_ORIGEM { get; set; }
public string CODIGO { get; set; }
public string IDADE { get; set; }
public string IDADE_CASO { get; set; }
public string TELEFONE_PRINCIPAL { get; set; }
public string ID_ORIGIN { get; set; }
public string DT_CRIACAO { get; set; }
public string STATUS { get; set; }
public string SEVERIDADE { get; set; }
public string RAZAO_SOCIAL { get; set; }
public string SEGMENTO { get; set; }
public string ORGANIZACAO { get; set; }
public string ID_TITLE { get; set; }
public string PLANO { get; set; }
public string TELEFONE_ALTERNATIVO { get; set; }
public string CPF { get; set; }
public string CNPJ { get; set; }
public string HISTORICO { get; set; }
public string NOTAS { get; set; }
public string NE_ID { get; set; }
public string ORIGIN_LEVEL { get; set; }
public string ID_SLA { get; set; }
public string SLA_LEVEL { get; set; }
public string ID_TYPE { get; set; }
public string PENDING { get; set; }
public string FG_TRATAMENTO { get; set; }
public Chamado()
{
}
}
}
VIEW
@model IEnumerable<ControleTTM.Models.Chamado>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
<div class="row">
<script>
$(document).ready(function () {
$('#chamados').DataTable();
});</script>
<div class="col-sm-3 col-md-3 col-lg-3">
<button onclick="location.href='@Url.Action("Tratar", "Tickets")'" class="btn btn-lg btn-success btn-width">
Tratar Chamado
</button>
</div>
<div class="col-sm-1 col-md-1 col-lg-1"></div>
<div class="col-sm-2 col-md-2 col-lg-2">
<button class="btn btn-lg btn-default btn-width">
Assigned
<span class="label label-primary custom-badge">42</span>
</button>
</div>
<div class="col-sm-2 col-md-2 col-lg-2">
<button class="btn btn-lg btn-default btn-width">
Working
<span class="label label-primary custom-badge">10</span>
</button>
</div>
<div class="col-sm-2 col-md-2 col-lg-2">
<button class="btn btn-lg btn-default btn-width">
Pending
<span class="label label-primary custom-badge">5</span>
</button>
</div>
<div class="col-sm-2 col-md-2 col-lg-2">
<button class="btn btn-lg btn-default btn-width">
Total
<span class="label label-primary custom-badge">100</span>
</button>
</div>
</div>
<table class="table table-bordered" id="chamados">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.CODIGO)
</th>
<th>
@Html.DisplayNameFor(model => model.IDADE)
</th>
<th>
@Html.DisplayNameFor(model => model.DESC_ORIGEM)
</th>
<th>
@Html.DisplayNameFor(model => model.ID_TITLE)
</th>
<th>
@Html.DisplayNameFor(model => model.ID_SLA)
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CODIGO)
</td>
<td>
@Html.DisplayFor(modelItem => item.IDADE)
</td>
<td>
@Html.DisplayFor(modelItem => item.DESC_ORIGEM)
</td>
<td>
@Html.DisplayFor(modelItem => item.ID_TITLE)
</td>
<td>
@Html.DisplayFor(modelItem => item.ID_SLA)
</td>
</tr>
}
</tbody>
I could not understand the question, you want to know why it is empty or not show in the view?
– M. Bertolazo
I want to know why this blank is not showing in the view. Where I am missing
– tatugf
your problem seems to be simple, here is a list of what you can do to check: 1- Check if the field is empty in the database, 2- Check if the list of the query has the filled item, 3- Try to feed Displayfor with other parameters, to treat if it is empty.
– M. Bertolazo
1 . OK - field is not empty in bank 2. I do not understand. 3. OK working.
– tatugf
from what I saw, this field is the only one of the table named B. you have already put a breakpoint in the Controller’s Return View(result) line to see if the result is bringing this field?
– aa_sp
In her model...
public virtual string DESC_ORIGEM { get; set; }
and in your controller you are returning aList<object>
not aList<Chamado>();
– Leandro Angelo
I don’t understand.. what should I do to solve?
– tatugf