Fix #70; Don't break front page on nulls

This commit is contained in:
Thomas Hounsell 2016-08-19 19:47:30 +01:00
parent ce4fbb16ec
commit 5190032029
3 changed files with 43 additions and 34 deletions

View File

@ -114,7 +114,7 @@ public async Task<FrontPage> SelectFrontPage()
}
}).Sort(sortByCompileDate).Limit(1);
fp.CurrentCanary = (await query.ToListAsync())[0];
fp.CurrentCanary = await query.FirstOrDefaultAsync();
query = _buildCollection.Find(new BsonDocument
{
@ -138,7 +138,7 @@ public async Task<FrontPage> SelectFrontPage()
}
}).Sort(sortByCompileDate).Limit(1);
fp.CurrentInsider = (await query.ToListAsync())[0];
fp.CurrentInsider = await query.FirstOrDefaultAsync();
query = _buildCollection.Find(new BsonDocument
{
@ -162,7 +162,7 @@ public async Task<FrontPage> SelectFrontPage()
}
}).Sort(sortByCompileDate).Limit(1);
fp.CurrentRelease = (await query.ToListAsync())[0];
fp.CurrentRelease = await query.FirstOrDefaultAsync();
return fp;
}

View File

@ -123,7 +123,7 @@ else
{
@class = "form-control"
})
<button onclick="$('#@Html.IdFor(model => model.LeakDate)').val('@DateTime.Now.ToString("dd/MM/yyyy")');return false;" class="btn btn-success btn-block btn-reset">@VariantTerms.Front_Today</button>
<button onclick="$('#@Html.IdFor(model => model.LeakDate)').val('@DateTime.Now.ToShortDateString()');return false;" class="btn btn-success btn-block btn-reset">@VariantTerms.Front_Today</button>
@Html.ValidationMessageFor(model => model.LeakDate)
</div>
</div>

View File

@ -11,39 +11,48 @@
<h3>@VariantTerms.Front_LatestBuilds</h3>
<div class="latest-flex">
<a href="@Url.Action("ViewBuild", new
@if (Model.CurrentCanary != null)
{
<a href="@Url.Action("ViewBuild", new
{
Model.CurrentCanary.Id
})" class="latest-flex-item latest-flex-red">
<h3 class="latest-flex-title">@VariantTerms.Front_CurrentCanary</h3>
<div class="latest-flex-detail">
<p class="latest-flex-build">@(Model.CurrentCanary.MajorVersion).@(Model.CurrentCanary.MinorVersion).@(Model.CurrentCanary.Number).@(Model.CurrentCanary.Revision)</p>
<p class="latest-flex-lab">@Model.CurrentCanary.Lab</p>
<p class="latest-flex-time">@Model.CurrentCanary.BuildTime.Value.ToString("HH:mm, dddd dd MMMM yyyy")</p>
</div>
</a>
<a href="@Url.Action("ViewBuild", new
{
Model.CurrentInsider.Id
})" class="latest-flex-item latest-flex-yellow">
<h3 class="latest-flex-title">@VariantTerms.Front_CurrentInsider</h3>
<div class="latest-flex-detail">
<p class="latest-flex-build">@(Model.CurrentInsider.MajorVersion).@(Model.CurrentInsider.MinorVersion).@(Model.CurrentInsider.Number).@(Model.CurrentInsider.Revision)</p>
<p class="latest-flex-lab">@Model.CurrentInsider.Lab</p>
<p class="latest-flex-time">@Model.CurrentInsider.BuildTime.Value.ToString("HH:mm, dddd dd MMMM yyyy")</p>
</div>
</a>
<a href="@Url.Action("ViewBuild", new
{
Model.CurrentRelease.Id
})" class="latest-flex-item latest-flex-green">
<h3 class="latest-flex-title">@VariantTerms.Front_CurrentRelease</h3>
<div class="latest-flex-detail">
<p class="latest-flex-build">@(Model.CurrentRelease.MajorVersion).@(Model.CurrentRelease.MinorVersion).@(Model.CurrentRelease.Number).@(Model.CurrentRelease.Revision)</p>
<p class="latest-flex-lab">@Model.CurrentRelease.Lab</p>
<p class="latest-flex-time">@Model.CurrentRelease.BuildTime.Value.ToString("HH:mm, dddd dd MMMM yyyy")</p>
</div>
</a>
<h3 class="latest-flex-title">@VariantTerms.Front_CurrentCanary</h3>
<div class="latest-flex-detail">
<p class="latest-flex-build">@(Model.CurrentCanary.MajorVersion).@(Model.CurrentCanary.MinorVersion).@(Model.CurrentCanary.Number).@(Model.CurrentCanary.Revision)</p>
<p class="latest-flex-lab">@Model.CurrentCanary.Lab</p>
<p class="latest-flex-time">@(Model.CurrentCanary.BuildTime?.ToString("HH:mm, dddd dd MMMM yyyy"))</p>
</div>
</a>
}
@if (Model.CurrentInsider != null)
{
<a href="@Url.Action("ViewBuild", new
{
Model.CurrentInsider.Id
})" class="latest-flex-item latest-flex-yellow">
<h3 class="latest-flex-title">@VariantTerms.Front_CurrentInsider</h3>
<div class="latest-flex-detail">
<p class="latest-flex-build">@(Model.CurrentInsider.MajorVersion).@(Model.CurrentInsider.MinorVersion).@(Model.CurrentInsider.Number).@(Model.CurrentInsider.Revision)</p>
<p class="latest-flex-lab">@Model.CurrentInsider.Lab</p>
<p class="latest-flex-time">@(Model.CurrentInsider.BuildTime?.ToString("HH:mm, dddd dd MMMM yyyy"))</p>
</div>
</a>
}
@if (Model.CurrentRelease != null)
{
<a href="@Url.Action("ViewBuild", new
{
Model.CurrentRelease.Id
})" class="latest-flex-item latest-flex-green">
<h3 class="latest-flex-title">@VariantTerms.Front_CurrentRelease</h3>
<div class="latest-flex-detail">
<p class="latest-flex-build">@(Model.CurrentRelease.MajorVersion).@(Model.CurrentRelease.MinorVersion).@(Model.CurrentRelease.Number).@(Model.CurrentRelease.Revision)</p>
<p class="latest-flex-lab">@Model.CurrentRelease.Lab</p>
<p class="latest-flex-time">@(Model.CurrentRelease.BuildTime?.ToString("HH:mm, dddd dd MMMM yyyy"))</p>
</div>
</a>
}
</div>
<a href="@Url.Action("IndexPage", new
{