This repository has been archived by the owner on Jul 20, 2020. It is now read-only.
/
View.cshtml
45 lines (40 loc) · 1.71 KB
/
View.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@{
var tagName = UrlData[0];
Page.Title = "View Tag - " + tagName;
var db = Database.Open("PhotoGallery");
var photos = db.Query(@"SELECT Photos.Id, Photos.FileTitle
FROM Photos, Photos_Tags
WHERE Photos.Id = Photos_Tags.Photos_Id AND Photos_Tags.Tags_TagName = @0", tagName).ToList();
var similarTags = db.Query(@"SELECT Tags_TagName AS TagName, COUNT(*) AS Count
FROM Photos_Tags WHERE Photos_Id IN (SELECT Photos_Id FROM Photos_Tags WHERE Tags_TagName = @0) AND Tags_TagName != @0
GROUP BY Tags_TagName
ORDER BY Count DESC", tagName).ToList();
}
<h1>@tagName</h1>
@if (photos.Count == 0) {
<p>There are no photos with this tag.</p>
} else {
if (photos.Count == 1) {
<p>There is one photo with this tag.</p>
} else {
<p>There are @photos.Count photos with this tag.</p>
}
<ul class="thumbnails">
@foreach (var photo in photos) {
<li>
<a href="@Href("~/Photo/View", photo.Id)">
<img alt="thumbnail of @Path.GetFileNameWithoutExtension(photo.FileTitle)" src="@Href("~/Photo/Thumbnail", photo.Id)" class="thumbnail-border" />
<span class="image-overlay">@Path.GetFileNameWithoutExtension(photo.FileTitle)</span>
</a>
</li>
}
</ul>
if (similarTags.Count > 0) {
<h2 class="similar-tags">Similar tags:</h2>
<ul class="tags">
@foreach (var t in similarTags) {
<li class="tag"><a href="@Href("~/Tag/View", t.TagName)">@t.TagName</a></li>
}
</ul>
}
}