Skip to main content
adicionou 79 caracteres ao conteúdo
Fonte Link
pnet
  • 14,9mil
  • 34
  • 113
  • 249

Fazendo assim resolveu

[HttpGet]
        public ActionResult Details(AzureDiscountGroupModel modelD)
        {
            var discount = _azureDiscountGroupService.GetAll();
            var list = new List<ResellerListModel>();

            var resellers = _resellerService.QueryAll()
                .Include(r => r.WhiteLabels)
                .ToList();

            foreach(var item in resellers)
            {
                list.Add(CreateListModelFrom(item));
            }

            ViewBag.Desconto = discount.Where(x => x.Id > 0);

            ViewBag.DetailReseller = list.Where(x => x.AzureDiscountGroupId == modelD.Id).ToList();

            return View(modelD);
        }

E na View fiz

@foreach (var item in ViewBag.DetailReseller as List<ResellerListModel>)
    {
    <tr align="center">
        <td>
            @(item.Name)
        </td>
        <td>
            @(item.Alias)
        </td>
        <td>
            @(item.WhiteLabel ? "Sim" : "Não")
        </td>
        <td>
            @(item.MpnId)
        </td>
        <td>
            @(item.CreatedOn)
        </td>
    </tr>
    }

O método CreateListModelFrom tem por finalidade popular a ResellerListModel

Fazendo assim resolveu

[HttpGet]
        public ActionResult Details(AzureDiscountGroupModel modelD)
        {
            var discount = _azureDiscountGroupService.GetAll();
            var list = new List<ResellerListModel>();

            var resellers = _resellerService.QueryAll()
                .Include(r => r.WhiteLabels)
                .ToList();

            foreach(var item in resellers)
            {
                list.Add(CreateListModelFrom(item));
            }

            ViewBag.Desconto = discount.Where(x => x.Id > 0);

            ViewBag.DetailReseller = list.Where(x => x.AzureDiscountGroupId == modelD.Id).ToList();

            return View(modelD);
        }

E na View fiz

@foreach (var item in ViewBag.DetailReseller as List<ResellerListModel>)
    {
    <tr align="center">
        <td>
            @(item.Name)
        </td>
        <td>
            @(item.Alias)
        </td>
        <td>
            @(item.WhiteLabel ? "Sim" : "Não")
        </td>
        <td>
            @(item.MpnId)
        </td>
        <td>
            @(item.CreatedOn)
        </td>
    </tr>
    }

Fazendo assim resolveu

[HttpGet]
        public ActionResult Details(AzureDiscountGroupModel modelD)
        {
            var discount = _azureDiscountGroupService.GetAll();
            var list = new List<ResellerListModel>();

            var resellers = _resellerService.QueryAll()
                .Include(r => r.WhiteLabels)
                .ToList();

            foreach(var item in resellers)
            {
                list.Add(CreateListModelFrom(item));
            }

            ViewBag.Desconto = discount.Where(x => x.Id > 0);

            ViewBag.DetailReseller = list.Where(x => x.AzureDiscountGroupId == modelD.Id).ToList();

            return View(modelD);
        }

E na View fiz

@foreach (var item in ViewBag.DetailReseller as List<ResellerListModel>)
    {
    <tr align="center">
        <td>
            @(item.Name)
        </td>
        <td>
            @(item.Alias)
        </td>
        <td>
            @(item.WhiteLabel ? "Sim" : "Não")
        </td>
        <td>
            @(item.MpnId)
        </td>
        <td>
            @(item.CreatedOn)
        </td>
    </tr>
    }

O método CreateListModelFrom tem por finalidade popular a ResellerListModel

Fonte Link
pnet
  • 14,9mil
  • 34
  • 113
  • 249

Fazendo assim resolveu

[HttpGet]
        public ActionResult Details(AzureDiscountGroupModel modelD)
        {
            var discount = _azureDiscountGroupService.GetAll();
            var list = new List<ResellerListModel>();

            var resellers = _resellerService.QueryAll()
                .Include(r => r.WhiteLabels)
                .ToList();

            foreach(var item in resellers)
            {
                list.Add(CreateListModelFrom(item));
            }

            ViewBag.Desconto = discount.Where(x => x.Id > 0);

            ViewBag.DetailReseller = list.Where(x => x.AzureDiscountGroupId == modelD.Id).ToList();

            return View(modelD);
        }

E na View fiz

@foreach (var item in ViewBag.DetailReseller as List<ResellerListModel>)
    {
    <tr align="center">
        <td>
            @(item.Name)
        </td>
        <td>
            @(item.Alias)
        </td>
        <td>
            @(item.WhiteLabel ? "Sim" : "Não")
        </td>
        <td>
            @(item.MpnId)
        </td>
        <td>
            @(item.CreatedOn)
        </td>
    </tr>
    }