Note that there are some explanatory texts on larger screens.

plurals
  1. POI've created the worst tag soup of all time (ASP.NET MVC 2)
    primarykey
    data
    text
    <p>I am staring at the worst mess, my monitor isn't tall enough to see what is going on, and VS 2010 is no help at all.</p> <p>I do not have any idea how to refactor this trash.</p> <p>It's 11 AM and I feel like pouring a drink already.</p> <p>Is this just the final proof that I have no business coding? Be honest.</p> <pre><code>&lt;div id="followedFriends"&gt; &lt;% if (Model.FollowedFriends.Count() &gt; 0) { foreach (var friend in Model.FollowedFriends) { %&gt; &lt;div id="friendContainer"&gt; &lt;div class="followedFriend"&gt; &lt;div class="userName"&gt; &lt;%= Html.ActionLink(friend.FoFriend.UserName, "Visitor", "Home", new {userID = friend.FoFriend.UserId}, null)%&gt;&lt;/div&gt; Currently reading: &lt;br /&gt; &lt;div class="bookLinks"&gt; &lt;% if (friend.BookCount != 0) { %&gt; &lt;% if (friend.BookCount &lt;= 5) { %&gt; &lt;%= friend.BookLinks%&gt; &lt;%} else { %&gt; &lt;%:Html.ActionLink(friend.BookCount + " different books.", "Visitor", "Home", new {userID = friend.FoFriend.UserId}, null)%&gt; &lt;%} } else { %&gt; Nothing, it appears... &lt;%}%&gt; &lt;/div&gt; &lt;%if (friend.ReviewCount != 0) {%&gt; New review for: &lt;div class="reviewLinks"&gt; &lt;%if (friend.ReviewCount &lt;= 5) { %&gt; &lt;%= friend.ReviewLinks%&gt; &lt;%} else {%&gt; &lt;%: friend.ReviewCount %&gt; different books &lt;%}%&gt;&lt;/div&gt; &lt;%} if (friend.QuoteCount != 0) {%&gt; &lt;span class="highlight"&gt;&amp;#9656&lt;/span&gt; &lt;%: friend.QuoteCount%&gt; new &lt;%if (friend.QuoteCount != 1) { %&gt;quotes &lt;%} else { %&gt; quote &lt;%} %&gt; &lt;%}%&gt; &lt;/div&gt; &lt;/div&gt; &lt;%} }%&gt; &lt;/div&gt; &lt;%} %&gt; </code></pre> <p><strong>Update</strong></p> <p>Since someone was asking, here is the pertinent portion of the View Model:</p> <pre><code> public class FollowedFriend { public aspnet_User FoFriend { get; set; } public string BookLinks { get; set; } public int BookCount { get; set; } public string ReviewLinks { get; set; } public int ReviewCount { get; set; } public int QuoteCount { get; set; } public FollowedFriend(Guid userID, DateTime lastVisit) { using (var context = new BookNotesEntities()) { FoFriend = context.aspnet_Users.SingleOrDefault(u =&gt; u.UserId == userID); var reading = context.Books.Where(b =&gt; b.UserID == userID &amp;&amp; b.CurrentlyReading == true).ToList(); BookCount = reading.Count; if (BookCount &lt;= 5) BookLinks = Book.ConvertBooksToLinks("Book/Details", reading); else BookLinks = ""; var recentBooks = context.Books.Where(b =&gt; b.UserID == userID &amp;&amp; b.Review.DateCreated &gt;= lastVisit).OrderByDescending(b =&gt; b.DateCreated).ToList(); if (recentBooks.Count &lt;= 5) ReviewLinks = Book.ConvertBooksToLinks("/Book/Details", recentBooks); else ReviewLinks = ""; ReviewCount = recentBooks.Count; QuoteCount = context.Quotes.Count(q =&gt; q.UserID == userID &amp;&amp; q.DateCreated &gt;= lastVisit); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload