Some fixes

Groundwork for #26, requires further work.
This commit is contained in:
Thomas Hounsell 2015-10-06 10:55:49 +01:00
parent ee4464da2b
commit b1058db213
3 changed files with 16 additions and 3 deletions

View File

@ -287,7 +287,7 @@ public async Task<ActionResult> editBuild(Guid id)
}
[Route("edit/{id}/"), Authorize, HttpPost]
public async Task<ActionResult> editBuild(long id, BuildModel build)
public async Task<ActionResult> editBuild(Guid id, BuildModel build)
{
if (ModelState.IsValid)
{

View File

@ -73,6 +73,8 @@ public class BuildModel
[EnumDataType(typeof(LevelOfFlight))]
public LevelOfFlight FlightLevel { get; set; }
public string LabUrl { get; set; }
public bool IsLeaked
{
get
@ -115,6 +117,8 @@ public string FullBuildString
return sb.ToString();
}
}
public string GenerateLabUrl() => Lab.Replace('/', '-').ToLower();
}
public class Build
@ -297,7 +301,8 @@ public async Task<List<BuildModel>> SelectFlight(LevelOfFlight flight, int limit
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task<List<BuildModel>> SelectLab(string lab, int skip, int limit)
{
return await _buildCollection.Find(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower()))
string labUrl = lab.Replace('/', '-').ToLower();
return await _buildCollection.Find(b => b.Lab != null && b.LabUrl == labUrl)
.SortByDescending(b => b.BuildTime)
.ThenByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
@ -470,12 +475,19 @@ public async Task<List<string>> SelectBuildLabs(byte major, byte minor)
public async Task Insert(BuildModel item)
{
item.Id = Guid.NewGuid();
item.LabUrl = item.GenerateLabUrl();
await _buildCollection.InsertOneAsync(item);
}
[DataObjectMethod(DataObjectMethodType.Insert, false)]
public async Task InsertAll(IEnumerable<BuildModel> items)
{
foreach(var item in items)
{
item.Id = Guid.NewGuid();
item.LabUrl = item.GenerateLabUrl();
}
await _buildCollection.InsertManyAsync(items);
}
@ -485,6 +497,7 @@ public async Task Update(BuildModel item)
BuildModel old = await SelectById(item.Id);
item.Added = old.Added;
item.Modified = DateTime.Now;
item.LabUrl = item.GenerateLabUrl();
await _buildCollection.ReplaceOneAsync(f => f.Id == item.Id, item);
}

View File

@ -158,7 +158,7 @@
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'buildfeed';
var disqus_url = 'https://buildfeed.net/actions/info/@Model.Id/';
var disqus_url = 'https://buildfeed.net/actions/info/@((object)Model.LegacyId ?? (object)Model.Id)/';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;