Click here to Skip to main content
15,886,835 members
Articles / Web Development / ASP.NET

Improving ASP.NET MVC MUSIC STORE more usability with DotNetAge in 30 minutes

Rate me:
Please Sign up or sign in to vote.
4.87/5 (12 votes)
23 Nov 2010GPL38 min read 83.1K   5.5K   32  
Using the DotNetAge to upgrade the ASP.NET Mvc Music Store add widgets and security features just in minutes.
<%@ Control Language="C#" Inherits="DNA.Mvc.DynamicUI.WidgetViewUserControl<IEnumerable<Article>>" %>
<%:Ajax.RenderAutoSettingForm(PropertyDescriptors, IDPrefix, IsDesignMode)%>
<% if (Model.Count() > 0)
   { %>
<table cellpadding="5px">
    <% 
        foreach (var article in Model)
        {
            if ((article.IsPrivate) || (!article.IsPublished))
            {
                if (!HttpContext.Current.Request.IsAuthenticated)
                    continue;
                if (!article.UserName.Equals(HttpContext.Current.User.Identity.Name, StringComparison.OrdinalIgnoreCase))
                    continue;
            }
            
            var content = article.GetGlobalizationContent();
    %>
    <tr>
        <td valign="top" align="center">
            <% if ((bool)UserData["ShowAuthorInfo"])
               {
                   var profile = article.Author.GetProfile();
            %>
            <table style="width: 100%; margin-bottom: 10px;">
                <tr>
                    <td valign="top" style="white-space: nowrap;">
                        <img src="<%:Url.Content("~/Content/Images/no-avatar.gif") %>" alt="" class="ui-corner-all"
                            style="width: 80px; height: 80px;" />
                        <div style="margin-top: 5px; text-align: center;">
                            <%:Html.UserLink(article.UserName) %>
                        </div>
                        <% if (!string.IsNullOrEmpty(profile["Location"].ToString()))
                           { %>
                        <div>
                            <%:Html.Global("RES_LOCATION")%>:
                            <%:profile["Location"]%></div>
                        <%} %>
                        <% if (!string.IsNullOrEmpty(profile["Email"].ToString()))
                           {%>
                        <%:Html.ImageLink("Contact me via mail", "mailto:"+profile["Email"].ToString(), Url.Content("~/Content/Images/email.png"))%>
                        <%} %>
                        <% if (!string.IsNullOrEmpty(profile["WebSite"] as string))
                           {%>
                        <%:Html.ImageLink("Web site",profile["WebSite"].ToString(),Url.Content("~/Content/Images/icon_homelink.gif")) %>
                        <%} %>
                    </td>
                </tr>
                <tr>
                    <td>
                        <%: !string.IsNullOrEmpty(article.Author.GetProfile()["Signature"] as string) ? Html.Encode(article.Author.GetProfile()["Signature"].ToString()) : ""%>
                    </td>
                </tr>
            </table>
            <%} %>
            <% if ((article.AllowComments) || article.TotalComments > 0)
               {   %>
            <div style="width: 65px; margin-bottom: 5px;" class="ui-state-highlight ui-corner-all">
                <div style="text-align: center; font-size: larger; font-weight: bold;">
                    <%:article.TotalComments%></div>
                <div style="text-align: center; font-size: smaller;">
                    <%:Html.Global("publishing", "Comments") %></div>
            </div>
            <%} %>
            <div style="width: 65px; margin-bottom: 5px;" class="ui-state-default ui-corner-all">
                <div style="text-align: center; font-size: larger; font-weight: bold;">
                    <%:article.TotalRatings %></div>
                <div style="text-align: center; font-size: smaller;">
                     <%:Html.Global("publishing", "Votes") %></div>
            </div>
            <div style="width: 65px;" class="ui-state-hover ui-corner-all">
                <div style="text-align: center; font-size: larger; font-weight: bold;">
                    <%:article.Reads %></div>
                <div style="text-align: center; font-size: smaller;">
                    <%:Html.Global("publishing", "Reads") %></div>
            </div>
        </td>
        <td  valign="top">
            <h2 class="ui-title" style="margin-top: 0px;">
                <a href="<%:article.GetPermaLinkUrl() %>">
                    <%:content.Title%></a>
                <% if (article.Posted > DateTime.Now.AddDays(-3))
                   {%>
                <img style="margin-left: 5px;" src="<%:Url.Content("~/Content/Images/new.gif") %>"
                    alt="[new]" />
                <%} %>
            </h2>
            <div id="<%:IDPrefix+"_bodyArea" %>">
                <% if (article.ContentFormat == 2)
                   { %>
                <%:Html.FormatWiKi(content.Body)%>
                <%}
                   else
                   { %>
                <%: Html.FormatXhtml(content.Body)%>
                <%} %>
                <% Html.ForceImageAutoSize(IDPrefix + "_bodyArea", -1, 520); %>
            </div>
            <div style="overflow: hidden; display: block; margin: 5px 0px 5px 0px; padding-top: 5px;
                border-top: 1px solid #cccccc;">
                <%: Html.ImageLinkList()
                                  .Options(opts =>
                                  {
                                      opts.CssClass = "ui-helper-reset";
                                      opts.ItemCssStyleText = "float:left;margin-right:5px;";
                                      opts.ImageCssStyleText = "float:left;margin-right:5px;";
                                      opts.TitleCssStyleText = "float:left;padding-top:2px;";
                                  })
                                  .Items(list =>
                                  {
                                      var parent = article.GetParent();
                                      var rootID =WebHost.EnablePersonalWeb ? WebSite.Open(article.UserName).DefaultCategory().ID : WebSite.Open().DefaultCategory().ID;
                                      list.Add(Html.Global("publishing", "FiledUnder"));
                                      list.Add(parent.ID == rootID ? Html.Global("publishing", "Uncategorized") : parent.Title, "", parent.GetPermalinkUrl().ToString());

                                      if (!string.IsNullOrEmpty(article.Categories))
                                      {
                                          var cats = article.GetCategories();
                                          foreach (var c in cats)
                                              list.Add(c.ID == rootID ? Html.Global("publishing", "Uncategorized") : c.Title, "", parent.GetPermalinkUrl().ToString());
                                      }
                                      if (!((bool)UserData["ShowAuthorInfo"]))
                                         list.Add(Html.Global("Publishing", "Author") + ":" + Html.UserLink(article.UserName), Url.Content("~/Content/Images/contact.gif"));
                                      list.Add(Html.Global(article.Posted), Url.Content("~/Content/Images/calender.gif"));

                                      if ((this.Context.Request.IsAuthenticated) && (this.Context.User.Identity.Name.Equals(article.UserName, StringComparison.OrdinalIgnoreCase)))
                                      {
                                          list.Add(Html.Global("RES_EDIT"), Url.Content("~/Content/Images/edit_page.png"), Url.Action("Edit", "Article", new { website = WebContext.Current.Web.Name, id = article.ID, Area = "Publishing" }));
                                      }

                                      if (article.AllowComments)
                                      {
                                          list.Add("", Url.Content("~/Content/Images/rss.png"));
                                          list.Add("Rss", "", Url.Action("RssFeed", "Article", new { website = WebContext.Current.Web.Name, id = article.ID, Area = "Publishing" }));
                                          list.Add("Atom", "", Url.Action("AtomFeed", "Article", new { website = WebContext.Current.Web.Name, id = article.ID, Area = "Publishing" }));
                                      }
                                  })
                                 .Render()
                %>
            </div>
        </td>
    </tr>
    <%} %>
</table>
<%}
   else
   { %>
<div class="ui-state-highlight" style="padding: 10px;">
    This is no article/blog found.
</div>
<%} %>
<%:Html.StartupScripts() %>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Architect DotNetAge
China China
In 1999, I started programming using Delphi, VB, VJ.From 2002 I started with .NET using C#.Since 2005 when i had became an EIP product manager I was focus on EIP and CMS technique. In 2008 i established dotnetage.com and started to shared my ideas and projects online. I believe "No shared no grow"

www.dotnetage.com

Comments and Discussions