ASP.NET Razor creare un banner per NopCommerce

Ho creato un semplice script in razor per umbraco, ma che può essere utilizzato anche in ASP.NET MVC che permette di ottenere un semplice banner con 4 prodotti tra quelli presenti in vetrina in un sito di e-commerce fatto con NopCommerce. Per funzionare però è necessario potersi connettere direttamente al database di nop.

@{
    var connStr = System.Configuration.ConfigurationManager.AppSettings["commerceDbDSN"];
    var t_prodotti = new System.Data.DataTable();
    var commerceAddress = "http://www.myecommerce.com";
 
    string sql =
        "SELECT TOP 4 " +
            "prod.ProductId, prod.ShortDescription, prod.SEName, pict.PictureID " +
        "FROM " +
            "Nop_Product as prod JOIN " +
            "Nop_ProductPicture as pict ON prod.ProductId = pict.ProductId " +
        "WHERE ShowOnHomePage = 1 and Deleted = 0 " +
        "ORDER BY NEWID()";
    
    (new System.Data.SqlClient.SqlDataAdapter(sql, connStr)).Fill(t_prodotti);
}
 
 
<div class="home-page-product-grid">
    <table>
        <tr>
            @foreach (System.Data.DataRow product in t_prodotti.Rows)
            {
                string descrizione = string.Format("{0}", product["ShortDescription"]).Replace('"', '\'');
                string pagina = string.Format("{0}-{1}.aspx", product["ProductId"], product["SEName"]);
                string img = string.Format("{0:0000000}_125.jpeg", product["PictureId"]);
                
                <td class="item-box">
                    <div class="product-item">
                        <div class="picture">
                            <a title="@descrizione" href="@commerceAddress/prodotti/@pagina" target="_blank">
                                <img title="@descrizione" src="@commerceAddress/images/thumbs/@img" alt="@descrizione" style="border-width:0px;" />
                            </a>
                        </div>
                        <h2 class="product-title">
                            <a href="@commerceAddress/prodotti/@pagina" target="_blank">@descrizione</a>
                        </h2>
                    </div>
                </td>
            }
        </tr>
    </table>
</div>