1
Inside that foreach
@foreach (var item in Model)
{
<tr>
<td>
<h3 id="subscription-@(item.SubscriptionId)" data-id="@item.SubscriptionId" class="item-accordion result-header">
@item.OrderId
</h3>
</td>
@if (Html.CurrentCustomer().Type == Atma.SND.CSP.SharedContracts.Contracts.Customers.CustomerTypeRequest.Reseller)
{
<td>
@item.CustomerEmail
</td>
}
@foreach(var dominio in ViewBag.Dominio)
{
<td>@dominio.Domain</td>
}
<td>
<span class="@(item.Status == "Ativa" ? "status-ativo" : "status-preto")">@item.Status</span>
<div id="subscription-content-@(item.SubscriptionId)" class="conteudo-item-accordion result-area display-none"></div>
</td>
<td>
@foreach (var product in item.Products)
{
<div>
@product
</div>
}
</td>
<td>
@Html.ActionLink("Detalhes", "Detail", "Subscription", new { id = item.SubscriptionId }, null)
</td>
<td>
<a class="see-order-details" href="@Url.Action("GetOrderDetail", new {id = item.OrderId})">Ver pedido</a>
</td>
</tr>
}
</tbody>
I did it
@foreach(var dominio in ViewBag.Dominio)
{
<td>@dominio.Domain</td>
}
It turns out that only the first item is printed on the screen and this should be because of being inside a foreach. I fill my Viewbag like this:
List<MicrosoftCustomer> lista = new List<MicrosoftCustomer>();
foreach (var item in customers)
{
lista.AddRange(ListaMicrosoftCustomer(item.CustomerMicrosoftId));
}
ViewBag.Dominio = lista;
Here in Controller are being filled in correctly, but my logic is wrong at the time of clicking on View. How do I correctly print the Domain in my Viewbag?
My model, the same from View
public class SearchSubscriptionResponse
{
public int SubscriptionId { get; set; }
public int OrderId { get; set; }
public int ResellerId { get; set; }
public int CustomerId { get; set; }
public Guid CustomerGuid { get; set; }
public string CustomerEmail { get; set; }
public string MicrosoftCustomerId { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime RenewOn { get; set; }
public string Status { get; set; }
public decimal EstimatedMonthlyPriceBRL { get; set; }
public bool PodeAtivar { get; set; }
public bool PodeAlterar { get; set; }
public List<string> Products { get; set; }
}
Here I take the Microsoftcustmer
private List<MicrosoftCustomer> ListaMicrosoftCustomer(string microsoftCustomerId)
{
return _microsoftCustomerService.Table.Where(x => x.Id == microsoftCustomerId).ToList();
}
Try to change that line
lista.AddRange(ListaMicrosoftCustomer(item.CustomerMicrosoftId));
forlista.Add(item.CustomerMicrosoftId);
. I could be wrong, because I don’t understand where you’re from, or what you areListaMicrosoftCustomer
– Matheus
@Matheus, is a method I created to store Microsoftcustomer. I will edit and post it. I edited and posted it
– pnet
I think you want to use
AddRange
, the methodAdd
, would be enough– Matheus
@Matheus, I think the whole question is not there, but the way the information is extracted in the View. That’s my bottleneck
– pnet