Do not page the list of Products

Asked

Viewed 38 times

-1

I don’t know anything about Razor or Webmatrix. I took a project already done by another developer and I came across two problems, I can not locate where the SQL queries to list the products and also do not know how to do so when listing the Products, not appear pagination, this is to list directly, all products of the database without paginar. Can you help me? Follow part of the code.

@model IEnumerable<MZANovoMVC4.Models.Produto>

@model PagedList.IPagedList<MZANovoMVC4.Models.Produto>
@using PagedList.Mvc;

@{
    ViewBag.Title = "Produtos - ";
    Layout = "~/Views/Shared/_Layout_Interno.cshtml";
}






<div class="container">
    <main id="content" class="col-md-12 main-blog" tabindex="-1" role="main" asd="1">
        <div class="row" style="margin-top:50px; margin-bottom:50px; margin-left:0px; margin-right:0px;">

            <div class="col-md-4 filter">
                <div class="filtro-produto">
                    <ul>
                        <li><a href="~/produtos">TODOS</a></li>
                        @foreach (var item in ViewBag.Categorias)
                        {
                            <li>
                                <a href="@Url.Action("Index", "Produto", new { idcategoria = item.IDCategoria, categoria = item.TituloTratado })">
                                    @item.Titulo
                                    <img class="sidebar-img" src="@item.Foto">
                                </a>
                            </li>
                        }

                    </ul>
                </div>
            </div>

            <main id="content" class="col-md-8 main-produto" tabindex="-1" role="main" asd="1">
                <div class="category-name">Linha Completa</div>
                <div class="produtos-topo" id="response">
                @foreach (var item in Model)
                {
                    <article class="box-produto post">
                        <img src="@item.Foto" width="800" height="450" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" 
                             alt="" sizes="(max-width: 800px) 100vw, 800px" data-lazy-loaded="true" style="display: block;">
                        <h3>@item.Titulo</h3>
                        @if (!string.IsNullOrEmpty(@item.Medidas))
                        {
                            <h4> Medidas:@item.Medidas</h4>
                        }                        
                        <a href="@Url.Action("Details", "Produto", new { id = item.IDProduto, name = item.TituloTratado})">Ver Produto</a>
                    </article>
                }


                </div>
                <div style="text-align:center;">
                    @Html.PagedListPager(Model, p => Url.Action("Index", new { p, b = ViewBag.Busca }))
                </div>
            </main>
        </div>
    </main>
</div>
  • Hello Fabio this project seems to be an MVC project in this case you should have a Controller that is where the logic is and where the data comes from.

1 answer

0

I cannot locate where the SQL queries are to list the products

This list is supplied on controller from the page, just search for your ActionResult.

Depending on how the project was structured, it may be coming from a Model and/or in the Model has a call to a class DAO that is all part CRUD an application. And yet there may be the possibility of having another business class that would be the .BLL.

I suggest you study a little on layers MVC and about the class .BLL.

But looking at your code, look for the Model Produto within the source of the project, that’s where this List, as well as the call at the bank.

On the issue of pagination you need to check otherwise some is being used plugin

  • From what I saw, you have this plugin in the file Packages.config <package id="Pagedlist" version="1.17.0.0" targetFramework="net45" /> <package id="Pagedlist.Mvc" version="4.5.0.0" targetFramework="net45" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.