From 48e161ca4a4a0056cb89a3d36e5a29cebc30a671 Mon Sep 17 00:00:00 2001
From: Thomas Hounsell
Date: Sun, 10 Jan 2016 22:23:13 +0000
Subject: [PATCH] Burn everything
This is where I NOP all the methods.
Also start re-implementing the data layer.
---
BuildFeed/BuildFeed.csproj | 10 +-
BuildFeed/Controllers/apiController.cs | 62 ++--
BuildFeed/Controllers/frontController.cs | 140 ++++-----
BuildFeed/Controllers/rssController.cs | 331 +++++++++++----------
BuildFeed/Controllers/supportController.cs | 251 ++++++++--------
BuildFeed/Models/Build/Build-Group.cs | 123 ++++----
BuildFeed/Models/Build/Build-Lab.cs | 79 +----
BuildFeed/Models/Build/Build-Source.cs | 29 +-
BuildFeed/Models/Build/Build-Version.cs | 77 +----
BuildFeed/Models/Build/Build-Year.cs | 45 +--
BuildFeed/Models/Build/Build.cs | 144 +++------
BuildFeed/Models/Build/BuildGroup.cs | 6 +-
BuildFeed/Models/Build/BuildModel.cs | 37 ++-
BuildFeed/Models/Build/BuildVersion.cs | 1 -
BuildFeed/Models/Build/LevelOfFlight.cs | 4 +-
BuildFeed/Models/Build/TypeOfSource.cs | 4 +-
BuildFeed/Models/MetaItem.cs | 6 +-
BuildFeed/Views/front/index.cshtml | 2 +-
BuildFeed/Views/front/viewBuild.cshtml | 12 +-
BuildFeed/Views/front/viewGroup.cshtml | 2 +-
BuildFeed/Views/front/viewLab.cshtml | 2 +-
BuildFeed/Views/front/viewSource.cshtml | 2 +-
BuildFeed/Views/front/viewVersion.cshtml | 2 +-
BuildFeed/Views/front/viewYear.cshtml | 2 +-
BuildFeed/Views/shared/_default.cshtml | 6 +-
BuildFeed/Views/shared/error.cshtml | 2 +-
BuildFeed/Views/support/sitemap.cshtml | 4 +-
27 files changed, 596 insertions(+), 789 deletions(-)
diff --git a/BuildFeed/BuildFeed.csproj b/BuildFeed/BuildFeed.csproj
index db2e03f..0fe2813 100644
--- a/BuildFeed/BuildFeed.csproj
+++ b/BuildFeed/BuildFeed.csproj
@@ -750,11 +750,11 @@
+
+
-
-
@@ -882,7 +882,7 @@
-
+
@@ -895,9 +895,9 @@
Designer
-
+
-
+
diff --git a/BuildFeed/Controllers/apiController.cs b/BuildFeed/Controllers/apiController.cs
index 2a1090e..563f2c0 100644
--- a/BuildFeed/Controllers/apiController.cs
+++ b/BuildFeed/Controllers/apiController.cs
@@ -22,19 +22,20 @@ public apiController() : base()
public async Task GetBuilds(int limit = 20, int skip = 0)
{
- var builds = await bModel.SelectInBuildOrder(limit, skip);
- return builds.ToArray();
+ throw new NotImplementedException();
+ // var builds = await bModel.SelectInBuildOrder(limit, skip);
+ // return builds.ToArray();
}
public async Task GetBuildGroups(int limit = 20, int skip = 20)
{
- var bgroups = await bModel.SelectBuildGroups(limit, skip);
+ var bgroups = await bModel.SelectAllGroups(limit, skip);
return bgroups.ToArray();
}
public async Task GetBuildsForBuildGroup(uint major, uint minor, uint number, uint? revision = null)
{
- var builds = await bModel.SelectBuildGroup(new BuildGroup()
+ var builds = await bModel.SelectGroup(new BuildGroup()
{
Major = major,
Minor = minor,
@@ -42,20 +43,21 @@ public async Task GetBuildsForBuildGroup(uint major, uint minor, u
Revision = revision
});
- return builds.Item2.ToArray();
+ return builds.ToArray();
}
public async Task> GetWin10Labs()
{
- List labs = new List();
- labs.AddRange(await bModel.SelectLabs(6, 4));
- labs.AddRange(await bModel.SelectLabs(10, 0));
+ throw new NotImplementedException();
+ //List labs = new List();
+ //labs.AddRange(await bModel.SelectLabs(6, 4));
+ //labs.AddRange(await bModel.SelectLabs(10, 0));
- return labs
- .GroupBy(l => l)
- .Select(l => l.Key)
- .Where(l => l.All(c => c != '('))
- .ToArray();
+ //return labs
+ // .GroupBy(l => l)
+ // .Select(l => l.Key)
+ // .Where(l => l.All(c => c != '('))
+ // .ToArray();
}
[HttpPost]
@@ -99,7 +101,7 @@ where s.Text.ToLower().Contains(id.ToLower())
orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending
select new SearchResult()
{
- Url = Url.Route("Source Root", new { controller = "front", action = "viewSource", source = s.Value }),
+ Url = Url.Route("Source Root", new { controller = "Front", action = "ViewSource", source = s.Value }),
Label = s.Text.Replace(id, "" + id + ""),
Title = s.Text,
Group = Common.SearchSource
@@ -108,12 +110,12 @@ orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascendi
results.AddRange(sourceResults);
- var versionResults = from v in await bModel.SelectVersions()
+ var versionResults = from v in await bModel.SelectAllVersions()
where $"{v.Major}.{v.Minor}".StartsWith(id)
orderby v.Major descending, v.Minor descending
select new SearchResult()
{
- Url = Url.Route("Version Root", new { controller = "front", action = "viewVersion", major = v.Major, minor = v.Minor }),
+ Url = Url.Route("Version Root", new { controller = "Front", action = "ViewVersion", major = v.Major, minor = v.Minor }),
Label = $"{v.Major}.{v.Minor}".Replace(id, "" + id + ""),
Title = "",
Group = Common.SearchVersion
@@ -122,12 +124,12 @@ orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascendi
results.AddRange(versionResults);
- var yearResults = from y in await bModel.SelectYears()
+ var yearResults = from y in await bModel.SelectAllYears()
where y.ToString().Contains(id)
orderby y descending
select new SearchResult()
{
- Url = Url.Route("Year Root", new { controller = "front", action = "viewYear", year = y }),
+ Url = Url.Route("Year Root", new { controller = "Front", action = "ViewYear", year = y }),
Label = y.ToString().Replace(id, "" + id + ""),
Title = "",
Group = Common.SearchYear
@@ -136,18 +138,18 @@ orderby y descending
results.AddRange(yearResults);
- var labResults = from l in await bModel.SearchBuildLabs(id)
- orderby l.IndexOf(id.ToLower()) ascending,
- l.Length ascending
- select new SearchResult()
- {
- Url = Url.Route("Lab Root", new { controller = "front", action = "viewLab", lab = l.Replace('/', '-') }),
- Label = l.Replace(id, $"{id}"),
- Title = l,
- Group = Common.SearchLab
- };
+ //var labResults = from l in await bModel.SearchBuildLabs(id)
+ // orderby l.IndexOf(id.ToLower()) ascending,
+ // l.Length ascending
+ // select new SearchResult()
+ // {
+ // Url = Url.Route("Lab Root", new { controller = "Front", action = "ViewLab", lab = l.Replace('/', '-') }),
+ // Label = l.Replace(id, $"{id}"),
+ // Title = l,
+ // Group = Common.SearchLab
+ // };
- results.AddRange(labResults);
+ //results.AddRange(labResults);
var buildResults = from b in await bModel.Select()
@@ -156,7 +158,7 @@ orderby b.FullBuildString.ToLower().IndexOf(id.ToLower(), StringComparison.Ordin
b.BuildTime descending
select new SearchResult()
{
- Url = Url.Route("Build", new { controller = "front", action = "viewBuild", id = b.Id }),
+ Url = Url.Route("Build", new { controller = "Front", action = "ViewBuild", id = b.Id }),
Label = b.FullBuildString.Replace(id, $"{id}"),
Title = b.FullBuildString,
Group = Common.SearchBuild
diff --git a/BuildFeed/Controllers/frontController.cs b/BuildFeed/Controllers/frontController.cs
index 959ccff..941aae4 100644
--- a/BuildFeed/Controllers/frontController.cs
+++ b/BuildFeed/Controllers/frontController.cs
@@ -1,6 +1,7 @@
using BuildFeed.Code;
using BuildFeed.Models;
using System;
+using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
@@ -9,40 +10,39 @@
using System.Linq;
using System.Threading.Tasks;
using System.Web.Mvc;
-using System.Web.Routing;
namespace BuildFeed.Controllers
{
- public class frontController : LocalController
+ public class FrontController : LocalController
{
- public const int PAGE_SIZE = 96;
+ private const int PAGE_SIZE = 96;
- private Build bModel;
- private MetaItem mModel;
+ private readonly Build _bModel;
+ private readonly MetaItem _mModel;
- public frontController() : base()
+ public FrontController() : base()
{
- bModel = new Build();
- mModel = new MetaItem();
+ _bModel = new Build();
+ _mModel = new MetaItem();
}
[Route("", Order = 1)]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
- public async Task index() { return await indexPage(1); }
+ public async Task Index() { return await IndexPage(1); }
[Route("page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
- public async Task indexPage(int page)
+ public async Task IndexPage(int page)
{
- var buildGroups = await bModel.SelectBuildGroups(PAGE_SIZE, (page - 1) * PAGE_SIZE);
+ var buildGroups = await _bModel.SelectAllGroups(PAGE_SIZE, (page - 1) * PAGE_SIZE);
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(
- Convert.ToDouble(await bModel.SelectBuildGroupsCount()) /
+ Convert.ToDouble(await _bModel.SelectAllGroupsCount()) /
Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
@@ -50,45 +50,47 @@ public async Task indexPage(int page)
return new HttpNotFoundResult();
}
- return View("index", buildGroups);
+ return View("Index", buildGroups);
}
[Route("group/{major}.{minor}.{number}.{revision}/")]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
- public async Task viewGroup(uint major, uint minor, uint number, uint? revision = null)
+ public async Task ViewGroup(uint major, uint minor, uint number, uint? revision = null)
{
- var builds = await bModel.SelectBuildGroup(new BuildGroup()
- {
- Major = major,
- Minor = minor,
- Build = number,
- Revision = revision
- });
+ BuildGroup bg = new BuildGroup()
+ {
+ Major = major,
+ Minor = minor,
+ Build = number,
+ Revision = revision
+ };
- return builds.Item2.Count() == 1 ?
- RedirectToAction("viewBuild", new { id = builds.Item2.Single().Id }) as ActionResult :
- View(builds);
+ var builds = await _bModel.SelectGroup(bg);
+
+ return builds.Count() == 1 ?
+ RedirectToAction(nameof(ViewBuild), new { id = builds.Single().Id }) as ActionResult :
+ View(new Tuple>(bg, builds));
}
[Route("build/{id:guid}/", Name = "Build")]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
- public async Task viewBuild(Guid id)
+ public async Task ViewBuild(Guid id)
{
- BuildModel b = await bModel.SelectById(id);
+ BuildModel b = await _bModel.SelectById(id);
if (b == null) return new HttpNotFoundResult();
return View(b);
}
[Route("build/{id:long}/", Name = "Build (Legacy)")]
- public async Task viewBuild(long id)
+ public async Task ViewBuild(long id)
{
- BuildModel b = await bModel.SelectByLegacyId(id);
+ BuildModel b = await _bModel.SelectByLegacyId(id);
if (b == null) return new HttpNotFoundResult();
- return RedirectToAction("viewBuild", new { id = b.Id });
+ return RedirectToAction(nameof(ViewBuild), new { id = b.Id });
}
[Route("twitter/{id:guid}/", Name = "Twitter")]
@@ -96,9 +98,9 @@ public async Task viewBuild(long id)
[OutputCache(Duration = 600, VaryByParam = "none")]
[CustomContentType(ContentType = "image/png", Order = 2)]
#endif
- public async Task twitterCard(Guid id)
+ public async Task TwitterCard(Guid id)
{
- BuildModel b = await bModel.SelectById(id);
+ BuildModel b = await _bModel.SelectById(id);
if (b == null) return new HttpNotFoundResult();
string path = Path.Combine(Server.MapPath("~/content/card/"), $"{b.Family}.png");
@@ -136,36 +138,36 @@ public async Task twitterCard(Guid id)
}
[Route("twitter/{id:long}/", Name = "Twitter (Legacy)")]
- public async Task twitterCard(long id)
+ public async Task TwitterCard(long id)
{
- BuildModel b = await bModel.SelectByLegacyId(id);
+ BuildModel b = await _bModel.SelectByLegacyId(id);
if (b == null) return new HttpNotFoundResult();
- return RedirectToAction("twitterCard", new { id = b.Id });
+ return RedirectToAction(nameof(TwitterCard), new { id = b.Id });
}
[Route("lab/{lab}/", Order = 1, Name = "Lab Root")]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
- public async Task viewLab(string lab) { return await viewLabPage(lab, 1); }
+ public async Task ViewLab(string lab) { return await ViewLabPage(lab, 1); }
[Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
- public async Task viewLabPage(string lab, int page)
+ public async Task ViewLabPage(string lab, int page)
{
- ViewBag.MetaItem = await mModel.SelectById(new MetaItemKey
+ ViewBag.MetaItem = await _mModel.SelectById(new MetaItemKey
{
Type = MetaType.Lab,
Value = lab
});
- var builds = await bModel.SelectLab(lab, (page - 1) * PAGE_SIZE, PAGE_SIZE);
+ var builds = await _bModel.SelectLab(lab, (page - 1) * PAGE_SIZE, PAGE_SIZE);
ViewBag.ItemId = builds.First().Lab;
ViewBag.PageNumber = page;
- ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await bModel.SelectLabCount(lab)) / Convert.ToDouble(PAGE_SIZE));
+ ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await _bModel.SelectLabCount(lab)) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
@@ -179,25 +181,25 @@ public async Task viewLabPage(string lab, int page)
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
- public async Task viewSource(TypeOfSource source) { return await viewSourcePage(source, 1); }
+ public async Task ViewSource(TypeOfSource source) { return await ViewSourcePage(source, 1); }
[Route("source/{source}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
- public async Task viewSourcePage(TypeOfSource source, int page)
+ public async Task ViewSourcePage(TypeOfSource source, int page)
{
- ViewBag.MetaItem = await mModel.SelectById(new MetaItemKey
+ ViewBag.MetaItem = await _mModel.SelectById(new MetaItemKey
{
Type = MetaType.Source,
Value = source.ToString()
});
ViewBag.ItemId = DisplayHelpers.GetDisplayTextForEnum(source);
- var builds = await bModel.SelectSource(source, (page - 1) * PAGE_SIZE, PAGE_SIZE);
+ var builds = await _bModel.SelectSource(source, (page - 1) * PAGE_SIZE, PAGE_SIZE);
ViewBag.PageNumber = page;
- ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await bModel.SelectSourceCount(source)) / Convert.ToDouble(PAGE_SIZE));
+ ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await _bModel.SelectSourceCount(source)) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
@@ -211,25 +213,25 @@ public async Task viewSourcePage(TypeOfSource source, int page)
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
- public async Task viewYear(int year) { return await viewYearPage(year, 1); }
+ public async Task ViewYear(int year) { return await ViewYearPage(year, 1); }
[Route("year/{year}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
- public async Task viewYearPage(int year, int page)
+ public async Task ViewYearPage(int year, int page)
{
- ViewBag.MetaItem = await mModel.SelectById(new MetaItemKey
+ ViewBag.MetaItem = await _mModel.SelectById(new MetaItemKey
{
Type = MetaType.Year,
Value = year.ToString()
});
ViewBag.ItemId = year.ToString();
- var builds = await bModel.SelectYear(year, (page - 1) * PAGE_SIZE, PAGE_SIZE);
+ var builds = await _bModel.SelectYear(year, (page - 1) * PAGE_SIZE, PAGE_SIZE);
ViewBag.PageNumber = page;
- ViewBag.PageCount = Math.Ceiling(await bModel.SelectYearCount(year) / Convert.ToDouble(PAGE_SIZE));
+ ViewBag.PageCount = Math.Ceiling(await _bModel.SelectYearCount(year) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
@@ -243,26 +245,26 @@ public async Task viewYearPage(int year, int page)
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
- public async Task viewVersion(uint major, uint minor) { return await viewVersionPage(major, minor, 1); }
+ public async Task ViewVersion(uint major, uint minor) { return await ViewVersionPage(major, minor, 1); }
[Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
- public async Task viewVersionPage(uint major, uint minor, int page)
+ public async Task ViewVersionPage(uint major, uint minor, int page)
{
string valueString = $"{major}.{minor}";
- ViewBag.MetaItem = await mModel.SelectById(new MetaItemKey
+ ViewBag.MetaItem = await _mModel.SelectById(new MetaItemKey
{
Type = MetaType.Version,
Value = valueString
});
ViewBag.ItemId = valueString;
- var builds = await bModel.SelectVersion(major, minor, (page - 1) * PAGE_SIZE, PAGE_SIZE);
+ var builds = await _bModel.SelectVersion(major, minor, (page - 1) * PAGE_SIZE, PAGE_SIZE);
ViewBag.PageNumber = page;
- ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await bModel.SelectVersionCount(major, minor)) / Convert.ToDouble(PAGE_SIZE));
+ ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await _bModel.SelectVersionCount(major, minor)) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
@@ -273,18 +275,18 @@ public async Task viewVersionPage(uint major, uint minor, int page
}
[Route("add/"), Authorize]
- public ActionResult addBuild()
+ public ActionResult AddBuild()
{
BuildModel b = new BuildModel()
{
SourceType = TypeOfSource.PrivateLeak,
FlightLevel = LevelOfFlight.None
};
- return View("editBuild", b);
+ return View("EditBuild", b);
}
[Route("add/"), Authorize, HttpPost]
- public async Task addBuild(BuildModel build)
+ public async Task AddBuild(BuildModel build)
{
if (ModelState.IsValid)
{
@@ -300,29 +302,29 @@ public async Task addBuild(BuildModel build)
{
build.LeakDate = DateTime.SpecifyKind(build.LeakDate.Value, DateTimeKind.Utc);
}
- await bModel.Insert(build);
+ await _bModel.Insert(build);
}
catch
{
- return View("editBuild", build);
+ return View("EditBuild", build);
}
- return RedirectToAction("viewBuild", new
+ return RedirectToAction(nameof(ViewBuild), new
{
id = build.Id
});
}
- return View("editBuild", build);
+ return View("EditBuild", build);
}
[Route("edit/{id}/"), Authorize]
- public async Task editBuild(Guid id)
+ public async Task EditBuild(Guid id)
{
- BuildModel b = await bModel.SelectById(id);
+ BuildModel b = await _bModel.SelectById(id);
return View(b);
}
[Route("edit/{id}/"), Authorize, HttpPost]
- public async Task editBuild(Guid id, BuildModel build)
+ public async Task EditBuild(Guid id, BuildModel build)
{
if (ModelState.IsValid)
{
@@ -336,23 +338,23 @@ public async Task editBuild(Guid id, BuildModel build)
{
build.LeakDate = DateTime.SpecifyKind(build.LeakDate.Value, DateTimeKind.Utc);
}
- await bModel.Update(build);
+ await _bModel.Update(build);
}
catch
{
return View(build);
}
- return RedirectToAction("viewBuild", new { id = build.Id });
+ return RedirectToAction(nameof(ViewBuild), new { id = build.Id });
}
return View(build);
}
[Route("delete/{id}/"), Authorize(Roles = "Administrators")]
- public async Task deleteBuild(Guid id)
+ public async Task DeleteBuild(Guid id)
{
- await bModel.DeleteById(id);
- return RedirectToAction("index");
+ await _bModel.DeleteById(id);
+ return RedirectToAction(nameof(Index));
}
}
}
\ No newline at end of file
diff --git a/BuildFeed/Controllers/rssController.cs b/BuildFeed/Controllers/rssController.cs
index ca459da..8d9d737 100644
--- a/BuildFeed/Controllers/rssController.cs
+++ b/BuildFeed/Controllers/rssController.cs
@@ -1,4 +1,5 @@
-using BuildFeed.Code;
+using System;
+using BuildFeed.Code;
using BuildFeed.Models;
using System.Collections.Generic;
using System.Linq;
@@ -24,225 +25,231 @@ public rssController() : base()
[Route("rss/compiled")]
public async Task index()
{
- var builds = await bModel.SelectInBuildOrder(RSS_SIZE, 0);
+ throw new NotImplementedException();
+ //var builds = await bModel.SelectInBuildOrder(RSS_SIZE, 0);
- RssDocument rdoc = new RssDocument()
- {
- Channel = new RssChannel()
- {
- Title = "BuildFeed RSS - Recently Compiled",
- Description = "",
- Generator = "BuildFeed.net RSS Controller",
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
- SkipHours = new List(),
- SkipDays = new List(),
+ //RssDocument rdoc = new RssDocument()
+ //{
+ // Channel = new RssChannel()
+ // {
+ // Title = "BuildFeed RSS - Recently Compiled",
+ // Description = "",
+ // Generator = "BuildFeed.net RSS Controller",
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
+ // SkipHours = new List(),
+ // SkipDays = new List(),
- Items = (from build in builds
- select new RssItem()
- {
- Title = build.FullBuildString,
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
- Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id })) },
- }).ToList()
- }
- };
+ // Items = (from build in builds
+ // select new RssItem()
+ // {
+ // Title = build.FullBuildString,
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"),
+ // Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "Front", id = build.Id })) },
+ // }).ToList()
+ // }
+ //};
- Response.ContentType = "application/rss+xml";
+ //Response.ContentType = "application/rss+xml";
- await Response.Output.WriteAsync(rdoc.ToXml());
+ //await Response.Output.WriteAsync(rdoc.ToXml());
- return new EmptyResult();
+ //return new EmptyResult();
}
[Route("rss/added")]
public async Task added()
{
- var builds = await bModel.SelectLatest(RSS_SIZE, 0);
+ throw new NotImplementedException();
+ //var builds = await bModel.SelectLatest(RSS_SIZE, 0);
- RssDocument rdoc = new RssDocument()
- {
- Channel = new RssChannel()
- {
- Title = "BuildFeed RSS - Recently Added",
- Description = "",
- Generator = "BuildFeed.net RSS Controller",
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
- SkipHours = new List(),
- SkipDays = new List(),
+ //RssDocument rdoc = new RssDocument()
+ //{
+ // Channel = new RssChannel()
+ // {
+ // Title = "BuildFeed RSS - Recently Added",
+ // Description = "",
+ // Generator = "BuildFeed.net RSS Controller",
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
+ // SkipHours = new List(),
+ // SkipDays = new List(),
- Items = (from build in builds
- select new RssItem()
- {
- Title = build.FullBuildString,
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
- Guid = new RssGuid()
- {
- IsPermaLink = true,
- Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
- },
- Category = new RssCategory() { Text = build.Family.ToString() },
- InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
- }).ToList()
- }
- };
+ // Items = (from build in builds
+ // select new RssItem()
+ // {
+ // Title = build.FullBuildString,
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"),
+ // Guid = new RssGuid()
+ // {
+ // IsPermaLink = true,
+ // Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"
+ // },
+ // Category = new RssCategory() { Text = build.Family.ToString() },
+ // InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
+ // }).ToList()
+ // }
+ //};
- Response.ContentType = "application/rss+xml";
+ //Response.ContentType = "application/rss+xml";
- await Response.Output.WriteAsync(rdoc.ToXml());
+ //await Response.Output.WriteAsync(rdoc.ToXml());
- return new EmptyResult();
+ //return new EmptyResult();
}
[Route("rss/leaked")]
public async Task leaked()
{
- var builds = await bModel.SelectLatestLeaked(RSS_SIZE, 0);
+ throw new NotImplementedException();
+ //var builds = await bModel.SelectLatestLeaked(RSS_SIZE, 0);
- RssDocument rdoc = new RssDocument()
- {
- Channel = new RssChannel()
- {
- Title = "BuildFeed RSS - Recently Leaked",
- Description = "",
- Generator = "BuildFeed.net RSS Controller",
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
- SkipHours = new List(),
- SkipDays = new List(),
+ //RssDocument rdoc = new RssDocument()
+ //{
+ // Channel = new RssChannel()
+ // {
+ // Title = "BuildFeed RSS - Recently Leaked",
+ // Description = "",
+ // Generator = "BuildFeed.net RSS Controller",
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
+ // SkipHours = new List(),
+ // SkipDays = new List(),
- Items = (from build in builds
- select new RssItem()
- {
- Title = build.FullBuildString,
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
- Guid = new RssGuid()
- {
- IsPermaLink = true,
- Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
- },
- InternalPubDate = new RssDate(build.LeakDate.Value).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
- }).ToList()
- }
- };
+ // Items = (from build in builds
+ // select new RssItem()
+ // {
+ // Title = build.FullBuildString,
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"),
+ // Guid = new RssGuid()
+ // {
+ // IsPermaLink = true,
+ // Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"
+ // },
+ // InternalPubDate = new RssDate(build.LeakDate.Value).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
+ // }).ToList()
+ // }
+ //};
- Response.ContentType = "application/rss+xml";
+ //Response.ContentType = "application/rss+xml";
- await Response.Output.WriteAsync(rdoc.ToXml());
+ //await Response.Output.WriteAsync(rdoc.ToXml());
- return new EmptyResult();
+ //return new EmptyResult();
}
[Route("rss/version")]
public async Task version()
{
- var builds = await bModel.SelectInVersionOrder(RSS_SIZE, 0);
+ throw new NotImplementedException();
+ //var builds = await bModel.SelectInVersionOrder(RSS_SIZE, 0);
- RssDocument rdoc = new RssDocument()
- {
- Channel = new RssChannel()
- {
- Title = "BuildFeed RSS - Highest Version",
- Description = "",
- Generator = "BuildFeed.net RSS Controller",
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
- SkipHours = new List(),
- SkipDays = new List(),
+ //RssDocument rdoc = new RssDocument()
+ //{
+ // Channel = new RssChannel()
+ // {
+ // Title = "BuildFeed RSS - Highest Version",
+ // Description = "",
+ // Generator = "BuildFeed.net RSS Controller",
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
+ // SkipHours = new List(),
+ // SkipDays = new List(),
- Items = (from build in builds
- select new RssItem()
- {
- Title = build.FullBuildString,
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
- Guid = new RssGuid()
- {
- IsPermaLink = true,
- Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
- },
- }).ToList()
- }
- };
+ // Items = (from build in builds
+ // select new RssItem()
+ // {
+ // Title = build.FullBuildString,
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"),
+ // Guid = new RssGuid()
+ // {
+ // IsPermaLink = true,
+ // Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"
+ // },
+ // }).ToList()
+ // }
+ //};
- Response.ContentType = "application/rss+xml";
+ //Response.ContentType = "application/rss+xml";
- await Response.Output.WriteAsync(rdoc.ToXml());
+ //await Response.Output.WriteAsync(rdoc.ToXml());
- return new EmptyResult();
+ //return new EmptyResult();
}
[Route("rss/flight/{id}")]
public async Task flight(LevelOfFlight id)
{
- var builds = await bModel.SelectFlight(id, RSS_SIZE, 0);
+ throw new NotImplementedException();
+ //var builds = await bModel.SelectFlight(id, RSS_SIZE, 0);
- RssDocument rdoc = new RssDocument()
- {
- Channel = new RssChannel()
- {
- Title = $"BuildFeed RSS - {id} Flight Level",
- Description = "",
- Generator = "BuildFeed.net RSS Controller",
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
- SkipHours = new List(),
- SkipDays = new List(),
+ //RssDocument rdoc = new RssDocument()
+ //{
+ // Channel = new RssChannel()
+ // {
+ // Title = $"BuildFeed RSS - {id} Flight Level",
+ // Description = "",
+ // Generator = "BuildFeed.net RSS Controller",
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
+ // SkipHours = new List(),
+ // SkipDays = new List(),
- Items = (from build in builds
- select new RssItem()
- {
- Title = build.FullBuildString,
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
- Guid = new RssGuid()
- {
- IsPermaLink = true,
- Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
- },
- }).ToList()
- }
- };
+ // Items = (from build in builds
+ // select new RssItem()
+ // {
+ // Title = build.FullBuildString,
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"),
+ // Guid = new RssGuid()
+ // {
+ // IsPermaLink = true,
+ // Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"
+ // },
+ // }).ToList()
+ // }
+ //};
- Response.ContentType = "application/rss+xml";
+ //Response.ContentType = "application/rss+xml";
- await Response.Output.WriteAsync(rdoc.ToXml());
+ //await Response.Output.WriteAsync(rdoc.ToXml());
- return new EmptyResult();
+ //return new EmptyResult();
}
[Route("rss/lab/{lab}")]
public async Task lab(string lab)
{
- var builds = await bModel.SelectLab(lab, 0, RSS_SIZE);
+ throw new NotImplementedException();
+ //var builds = await bModel.SelectLab(lab, 0, RSS_SIZE);
- RssDocument rdoc = new RssDocument()
- {
- Channel = new RssChannel()
- {
- Title = $"BuildFeed RSS - {lab} Lab",
- Description = "",
- Generator = "BuildFeed.net RSS Controller",
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
- SkipHours = new List(),
- SkipDays = new List(),
+ //RssDocument rdoc = new RssDocument()
+ //{
+ // Channel = new RssChannel()
+ // {
+ // Title = $"BuildFeed RSS - {lab} Lab",
+ // Description = "",
+ // Generator = "BuildFeed.net RSS Controller",
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
+ // SkipHours = new List(),
+ // SkipDays = new List(),
- Items = (from build in builds
- select new RssItem()
- {
- Title = build.FullBuildString,
- Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
- Guid = new RssGuid()
- {
- IsPermaLink = true,
- Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
- },
- }).ToList()
- }
- };
+ // Items = (from build in builds
+ // select new RssItem()
+ // {
+ // Title = build.FullBuildString,
+ // Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"),
+ // Guid = new RssGuid()
+ // {
+ // IsPermaLink = true,
+ // Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "Front", id = build.Id })}"
+ // },
+ // }).ToList()
+ // }
+ //};
- Response.ContentType = "application/rss+xml";
+ //Response.ContentType = "application/rss+xml";
- await Response.Output.WriteAsync(rdoc.ToXml());
+ //await Response.Output.WriteAsync(rdoc.ToXml());
- return new EmptyResult();
+ //return new EmptyResult();
}
}
}
\ No newline at end of file
diff --git a/BuildFeed/Controllers/supportController.cs b/BuildFeed/Controllers/supportController.cs
index f70b7e3..fdbe02e 100644
--- a/BuildFeed/Controllers/supportController.cs
+++ b/BuildFeed/Controllers/supportController.cs
@@ -129,7 +129,7 @@ public ActionResult register(RegistrationUser ru)
[Route("rss")]
public async Task rss()
{
- ViewBag.Labs = await bModel.SelectLabs();
+ ViewBag.Labs = await bModel.SelectAllLabs();
return View();
}
@@ -139,135 +139,136 @@ public async Task rss()
#endif
public async Task sitemap()
{
- var builds = await bModel.SelectInVersionOrder();
- Dictionary actions = new Dictionary();
- actions.Add("Pages", new[]
- {
- new SitemapPagedAction()
- {
- UrlParams = new RouteValueDictionary(new
- {
- controller = "front",
- action = "index",
- page = 1
- }),
- Pages = (builds.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
- }
- });
+ throw new NotImplementedException();
+ //var builds = await bModel.SelectInVersionOrder();
+ //Dictionary actions = new Dictionary();
+ //actions.Add("Pages", new[]
+ // {
+ // new SitemapPagedAction()
+ // {
+ // UrlParams = new RouteValueDictionary(new
+ // {
+ // controller = "front",
+ // action = "index",
+ // page = 1
+ // }),
+ // Pages = (builds.Count() + (FrontController.PageSize - 1)) / FrontController.PageSize
+ // }
+ // });
- actions.Add("Versions", (from b in builds
- group b by new BuildVersion()
- {
- Major = b.MajorVersion,
- Minor = b.MinorVersion
- }
- into bv
- orderby bv.Key.Major descending,
- bv.Key.Minor descending
- select new SitemapPagedAction()
- {
- Name = $"{Common.ProductName} {bv.Key.Major}.{bv.Key.Minor}",
- UrlParams = new RouteValueDictionary(new
- {
- controller = "front",
- action = "viewVersion",
- major = bv.Key.Major,
- minor = bv.Key.Minor,
- page = 1
- }),
- Pages = (bv.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
- }).ToArray());
+ //actions.Add("Versions", (from b in builds
+ // group b by new BuildVersion()
+ // {
+ // Major = b.MajorVersion,
+ // Minor = b.MinorVersion
+ // }
+ // into bv
+ // orderby bv.Key.Major descending,
+ // bv.Key.Minor descending
+ // select new SitemapPagedAction()
+ // {
+ // Name = $"{Common.ProductName} {bv.Key.Major}.{bv.Key.Minor}",
+ // UrlParams = new RouteValueDictionary(new
+ // {
+ // controller = "front",
+ // action = "viewVersion",
+ // major = bv.Key.Major,
+ // minor = bv.Key.Minor,
+ // page = 1
+ // }),
+ // Pages = (bv.Count() + (FrontController.PageSize - 1)) / FrontController.PageSize
+ // }).ToArray());
- actions.Add("Labs", (from b in builds
- where !string.IsNullOrEmpty(b.Lab)
- group b by b.Lab
- into bv
- orderby bv.Key
- select new SitemapPagedAction()
- {
- Name = bv.Key,
- UrlParams = new RouteValueDictionary(new
- {
- controller = "front",
- action = "viewLab",
- lab = bv.Key,
- page = 1
- }),
- Pages = (bv.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
- }).ToArray());
+ //actions.Add("Labs", (from b in builds
+ // where !string.IsNullOrEmpty(b.Lab)
+ // group b by b.Lab
+ // into bv
+ // orderby bv.Key
+ // select new SitemapPagedAction()
+ // {
+ // Name = bv.Key,
+ // UrlParams = new RouteValueDictionary(new
+ // {
+ // controller = "front",
+ // action = "viewLab",
+ // lab = bv.Key,
+ // page = 1
+ // }),
+ // Pages = (bv.Count() + (FrontController.PageSize - 1)) / FrontController.PageSize
+ // }).ToArray());
- actions.Add("Years", (from b in builds
- where b.BuildTime.HasValue
- group b by b.BuildTime.Value.Year
- into bv
- orderby bv.Key descending
- select new SitemapPagedAction()
- {
- Name = bv.Key.ToString(),
- UrlParams = new RouteValueDictionary(new
- {
- controller = "front",
- action = "viewYear",
- year = bv.Key,
- page = 1
- }),
- Pages = (bv.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
- }).ToArray());
+ //actions.Add("Years", (from b in builds
+ // where b.BuildTime.HasValue
+ // group b by b.BuildTime.Value.Year
+ // into bv
+ // orderby bv.Key descending
+ // select new SitemapPagedAction()
+ // {
+ // Name = bv.Key.ToString(),
+ // UrlParams = new RouteValueDictionary(new
+ // {
+ // controller = "front",
+ // action = "viewYear",
+ // year = bv.Key,
+ // page = 1
+ // }),
+ // Pages = (bv.Count() + (FrontController.PageSize - 1)) / FrontController.PageSize
+ // }).ToArray());
- actions.Add("Sources", (from b in builds
- group b by b.SourceType
- into bv
- orderby bv.Key
- select new SitemapPagedAction()
- {
- Name = DisplayHelpers.GetDisplayTextForEnum(bv.Key),
- UrlParams = new RouteValueDictionary(new
- {
- controller = "front",
- action = "viewSource",
- source = bv.Key,
- page = 1
- }),
- Pages = (bv.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
- }).ToArray());
+ //actions.Add("Sources", (from b in builds
+ // group b by b.SourceType
+ // into bv
+ // orderby bv.Key
+ // select new SitemapPagedAction()
+ // {
+ // Name = DisplayHelpers.GetDisplayTextForEnum(bv.Key),
+ // UrlParams = new RouteValueDictionary(new
+ // {
+ // controller = "front",
+ // action = "viewSource",
+ // source = bv.Key,
+ // page = 1
+ // }),
+ // Pages = (bv.Count() + (FrontController.PageSize - 1)) / FrontController.PageSize
+ // }).ToArray());
- SitemapData model = new SitemapData()
- {
- Builds = (from b in builds
- group b by new
- {
- Major = b.MajorVersion,
- Minor = b.MinorVersion,
- Build = b.Number,
- Revision = b.Revision
- } into bg
- orderby bg.Key.Major descending,
- bg.Key.Minor descending,
- bg.Key.Build descending,
- bg.Key.Revision descending
- select new SitemapDataBuildGroup()
- {
- Id = new BuildGroup() {
- Major = bg.Key.Major,
- Minor = bg.Key.Minor,
- Build = bg.Key.Build,
- Revision = bg.Key.Revision
- },
- Builds = (from bgb in bg
- select new SitemapDataBuild()
- {
- Id = bgb.Id,
- Name = bgb.FullBuildString
- }).ToArray()
- }).ToArray(),
+ //SitemapData model = new SitemapData()
+ //{
+ // Builds = (from b in builds
+ // group b by new
+ // {
+ // Major = b.MajorVersion,
+ // Minor = b.MinorVersion,
+ // Build = b.Number,
+ // Revision = b.Revision
+ // } into bg
+ // orderby bg.Key.Major descending,
+ // bg.Key.Minor descending,
+ // bg.Key.Build descending,
+ // bg.Key.Revision descending
+ // select new SitemapDataBuildGroup()
+ // {
+ // Id = new BuildGroup() {
+ // Major = bg.Key.Major,
+ // Minor = bg.Key.Minor,
+ // Build = bg.Key.Build,
+ // Revision = bg.Key.Revision
+ // },
+ // Builds = (from bgb in bg
+ // select new SitemapDataBuild()
+ // {
+ // Id = bgb.Id,
+ // Name = bgb.FullBuildString
+ // }).ToArray()
+ // }).ToArray(),
- Actions = actions,
- Labs = (from b in builds
- group b by b.Lab into lab
- select lab.Key).ToArray()
- };
+ // Actions = actions,
+ // Labs = (from b in builds
+ // group b by b.Lab into lab
+ // select lab.Key).ToArray()
+ //};
- return View(model);
+ //return View(model);
}
[Route("xml-sitemap/")]
@@ -281,14 +282,14 @@ public async Task xmlsitemap()
// home page
XElement home = new XElement(xn + "url");
- home.Add(new XElement(xn + "loc", Request.Url.GetLeftPart(UriPartial.Authority) + "/"));
+ home.Add(new XElement(xn + "loc", Request.Url?.GetLeftPart(UriPartial.Authority) + "/"));
home.Add(new XElement(xn + "changefreq", "daily"));
xlist.Add(home);
foreach (var b in await bModel.Select())
{
XElement url = new XElement(xn + "url");
- url.Add(new XElement(xn + "loc", Request.Url.GetLeftPart(UriPartial.Authority) + Url.Action("viewBuild", "front", new { id = b.Id })));
+ url.Add(new XElement(xn + "loc", Request.Url?.GetLeftPart(UriPartial.Authority) + Url.Action("viewBuild", "Front", new { id = b.Id })));
if (b.Modified != DateTime.MinValue)
{
url.Add(new XElement(xn + "lastmod", b.Modified.ToString("yyyy-MM-dd")));
diff --git a/BuildFeed/Models/Build/Build-Group.cs b/BuildFeed/Models/Build/Build-Group.cs
index 3cf938e..e71e24f 100644
--- a/BuildFeed/Models/Build/Build-Group.cs
+++ b/BuildFeed/Models/Build/Build-Group.cs
@@ -1,72 +1,87 @@
-using BuildFeed.Models.ViewModel.Front;
-using MongoDB.Bson;
-using MongoDB.Driver;
-using System;
+using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
+using BuildFeed.Models.ViewModel.Front;
+using MongoDB.Bson;
+using MongoDB.Driver;
namespace BuildFeed.Models
{
public partial class Build
{
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task>> SelectBuildGroup(BuildGroup bGroup)
+ public async Task SelectAllGroups(int limit = -1, int skip = 0)
{
- var pipeline = _buildCollection
- .Find(new BsonDocument
- {
- { "MajorVersion", BsonValue.Create(bGroup.Major) },
- { "MinorVersion", BsonValue.Create(bGroup.Minor) },
- { "Number", BsonValue.Create(bGroup.Build) },
- { "Revision", BsonValue.Create(bGroup.Revision) },
- })
- .SortByDescending(b => b.BuildTime);
+ var query = _buildCollection.Aggregate()
+ .Group(
+ new BsonDocument
+ {
+ new BsonElement(
+ "_id", new BsonDocument
+ {
+ new BsonElement(nameof(BuildGroup.Major), $"${nameof(BuildModel.MajorVersion)}"),
+ new BsonElement(nameof(BuildGroup.Minor), $"${nameof(BuildModel.MinorVersion)}"),
+ new BsonElement(nameof(BuildGroup.Build), $"${nameof(BuildModel.Number)}"),
+ new BsonElement(nameof(BuildGroup.Revision), $"${nameof(BuildModel.Revision)}")
+ }),
+ new BsonElement("date", new BsonDocument("$max", $"${nameof(BuildModel.BuildTime)}")),
+ new BsonElement("count", new BsonDocument("$sum", 1))
+ })
+ .Sort(
+ new BsonDocument
+ {
+ new BsonElement($"_id.{nameof(BuildGroup.Major)}", -1),
+ new BsonElement($"_id.{nameof(BuildGroup.Minor)}", -1),
+ new BsonElement($"_id.{nameof(BuildGroup.Build)}", -1),
+ new BsonElement($"_id.{nameof(BuildGroup.Revision)}", -1)
+ });
- return new Tuple>(bGroup, await pipeline.ToListAsync());
+ if (limit > 0)
+ {
+ query = query
+ .Limit(limit);
+ }
+
+ var grouping = await query
+ .Skip(skip)
+ .ToListAsync();
+
+ return (from g in grouping
+ select new FrontBuildGroup
+ {
+ Key = new BuildGroup
+ {
+ Major = (uint) g["_id"].AsBsonDocument[nameof(BuildGroup.Major)].AsInt32,
+ Minor = (uint) g["_id"].AsBsonDocument[nameof(BuildGroup.Minor)].AsInt32,
+ Build = (uint) g["_id"].AsBsonDocument[nameof(BuildGroup.Build)].AsInt32,
+ Revision = (uint) g["_id"].AsBsonDocument[nameof(BuildGroup.Revision)].AsInt32
+ },
+ LastBuild = g["date"].ToNullableUniversalTime(),
+ BuildCount = g["count"].AsInt32
+ }).ToArray();
}
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectBuildGroups(int limit, int skip)
+ public async Task SelectAllGroupsCount()
{
- return await _buildCollection.Aggregate()
- .Group(b => new BuildGroup()
- {
- Major = b.MajorVersion,
- Minor = b.MinorVersion,
- Build = b.Number,
- Revision = b.Revision
- },
- bg => new FrontBuildGroup()
- {
- Key = bg.Key,
- BuildCount = bg.Count(),
- LastBuild = bg.Max(b => b.BuildTime)
- })
- .SortByDescending(b => b.Key.Major)
- .ThenByDescending(b => b.Key.Minor)
- .ThenByDescending(b => b.Key.Build)
- .ThenByDescending(b => b.Key.Revision)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
+ var grouping = await _buildCollection.Aggregate()
+ .Group(
+ new BsonDocument
+ {
+ new BsonElement(
+ "_id", new BsonDocument
+ {
+ new BsonElement(nameof(BuildGroup.Major), $"${nameof(BuildModel.MajorVersion)}"),
+ new BsonElement(nameof(BuildGroup.Minor), $"${nameof(BuildModel.MinorVersion)}"),
+ new BsonElement(nameof(BuildGroup.Build), $"${nameof(BuildModel.Number)}"),
+ new BsonElement(nameof(BuildGroup.Revision), $"${nameof(BuildModel.Revision)}")
+ })
+ })
+ .ToListAsync();
+ return grouping.Count;
}
- [DataObjectMethod(DataObjectMethodType.Select, true)]
- public async Task SelectBuildGroupsCount()
- {
- var pipeline = _buildCollection.Aggregate()
- .Group(b => new BuildGroup()
- {
- Major = b.MajorVersion,
- Minor = b.MinorVersion,
- Build = b.Number,
- Revision = b.Revision
- },
- bg => new BsonDocument());
+ public async Task> SelectGroup(BuildGroup group, int limit = -1, int skip = 0) { throw new NotImplementedException(); }
- return (await pipeline.ToListAsync()).Count;
- }
+ public async Task> SelectGroupCount(BuildGroup group) { throw new NotImplementedException(); }
}
}
\ No newline at end of file
diff --git a/BuildFeed/Models/Build/Build-Lab.cs b/BuildFeed/Models/Build/Build-Lab.cs
index 1f5bb32..3cbe06d 100644
--- a/BuildFeed/Models/Build/Build-Lab.cs
+++ b/BuildFeed/Models/Build/Build-Lab.cs
@@ -1,86 +1,19 @@
-using MongoDB.Driver;
-using System;
+using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
+using System.Web;
namespace BuildFeed.Models
{
public partial class Build
{
+ public Task SelectAllLabs(int limit = -1, int skip = 0) { throw new NotImplementedException(); }
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectLab(string lab, int skip, int limit)
- {
- 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)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
- }
+ public async Task SelectAllLabsCount() { throw new NotImplementedException(); }
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectLabs()
- {
- var result = await _buildCollection.Aggregate()
- .Match(b => b.Lab != null)
- .Match(b => b.Lab != "")
- .Group(b => b.Lab.ToLower(),
- // incoming bullshit hack
- bg => new Tuple(bg.Key))
- .SortBy(b => b.Item1)
- .ToListAsync();
+ public async Task> SelectLab(string lab, int limit = -1, int skip = 0) { throw new NotImplementedException(); }
- // work ourselves out of aforementioned bullshit hack
- return result.Select(b => b.Item1).ToList();
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectLabs(uint major, uint minor)
- {
- var result = await _buildCollection.Aggregate()
- .Match(b => b.MajorVersion == major)
- .Match(b => b.MinorVersion == minor)
- .Match(b => b.Lab != null)
- .Match(b => b.Lab != "")
- .Group(b => b.Lab.ToLower(),
- // incoming bullshit hack
- bg => new Tuple(bg.Key))
- .SortBy(b => b.Item1)
- .ToListAsync();
-
- // work ourselves out of aforementioned bullshit hack
- return result.Select(b => b.Item1).ToList();
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task SelectLabCount(string lab)
- {
- string labUrl = lab.Replace('/', '-').ToLower();
- return await _buildCollection.Find(b => b.Lab != null && b.LabUrl == labUrl)
- .CountAsync();
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SearchBuildLabs(string query)
- {
- var result = await _buildCollection.Aggregate()
- .Match(b => b.Lab != null)
- .Match(b => b.Lab != "")
- .Match(b => b.Lab.ToLower().Contains(query.ToLower()))
- .Group(b => b.Lab.ToLower(),
- // incoming bullshit hack
- bg => new Tuple(bg.Key))
- .ToListAsync();
-
- // work ourselves out of aforementioned bullshit hack
- return result.Select(b => b.Item1).ToList();
- }
+ public async Task SelectLabCount(string lab) { throw new NotImplementedException(); }
}
}
\ No newline at end of file
diff --git a/BuildFeed/Models/Build/Build-Source.cs b/BuildFeed/Models/Build/Build-Source.cs
index eaacf85..2d17f0e 100644
--- a/BuildFeed/Models/Build/Build-Source.cs
+++ b/BuildFeed/Models/Build/Build-Source.cs
@@ -1,32 +1,19 @@
-using MongoDB.Driver;
+using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
+using System.Web;
namespace BuildFeed.Models
{
public partial class Build
{
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectSource(TypeOfSource source, int skip, int limit)
- {
- return await _buildCollection.Find(b => b.SourceType == source)
- .SortByDescending(b => b.BuildTime)
- .ThenByDescending(b => b.MajorVersion)
- .ThenByDescending(b => b.MinorVersion)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
- }
+ public Task SelectAllSources(int limit = -1, int skip = 0) { throw new NotImplementedException(); }
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task SelectSourceCount(TypeOfSource source)
- {
- return await _buildCollection.Find(b => b.SourceType == source)
- .CountAsync();
- }
+ public async Task SelectAllSourcesCount() { throw new NotImplementedException(); }
+
+ public async Task> SelectSource(TypeOfSource source, int limit = -1, int skip = 0) { throw new NotImplementedException(); }
+
+ public async Task SelectSourceCount(TypeOfSource source) { throw new NotImplementedException(); }
}
}
\ No newline at end of file
diff --git a/BuildFeed/Models/Build/Build-Version.cs b/BuildFeed/Models/Build/Build-Version.cs
index 4a7f95b..3f418c6 100644
--- a/BuildFeed/Models/Build/Build-Version.cs
+++ b/BuildFeed/Models/Build/Build-Version.cs
@@ -1,84 +1,19 @@
-using MongoDB.Bson;
-using MongoDB.Driver;
-using System;
+using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
+using System.Web;
namespace BuildFeed.Models
{
public partial class Build
{
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectInVersionOrder()
- {
- return await _buildCollection.Find(new BsonDocument())
- .SortByDescending(b => b.MajorVersion)
- .ThenByDescending(b => b.MinorVersion)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .ThenByDescending(b => b.BuildTime)
- .ToListAsync();
- }
+ public async Task SelectAllVersions(int limit = -1, int skip = 0) { throw new NotImplementedException(); }
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectInVersionOrder(int limit, int skip)
- {
- return await _buildCollection.Find(new BsonDocument())
- .SortByDescending(b => b.MajorVersion)
- .ThenByDescending(b => b.MinorVersion)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .ThenByDescending(b => b.BuildTime)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
- }
+ public async Task SelectAllVersionsCount() { throw new NotImplementedException(); }
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectVersion(uint major, uint minor, int skip, int limit)
- {
- byte bMajor = Convert.ToByte(major), bMinor = Convert.ToByte(minor);
- var test = await _buildCollection.Find(Builders.Filter.And(Builders.Filter.Eq(b => b.MajorVersion, bMajor), Builders.Filter.Eq(b => b.MinorVersion, bMinor)))
- .SortByDescending(b => b.BuildTime)
- .ThenByDescending(b => b.MajorVersion)
- .ThenByDescending(b => b.MinorVersion)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
- return test;
- }
+ public async Task> SelectVersion(uint major, uint minor, int limit = -1, int skip = 0) { throw new NotImplementedException(); }
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectVersions()
- {
- var result = await _buildCollection.Aggregate()
- // the group method in mongodb's c# driver sucks balls and throws a hissy fit over far too much.
- .Group(b => new BuildVersion(b.MajorVersion, b.MinorVersion), bg => new BsonDocument())
- .ToListAsync();
-
- // work ourselves out of aforementioned bullshit hack
- var typed = from r in result
- select new BuildVersion
- {
- Major = (uint)r["_id"]["Major"].ToInt32(),
- Minor = (uint)r["_id"]["Minor"].ToInt32()
- };
-
- return (from t in typed
- orderby t.Major descending,
- t.Minor descending
- select t).ToList();
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task SelectVersionCount(uint major, uint minor)
- {
- return await _buildCollection.Find(Builders.Filter.And(Builders.Filter.Eq(b => b.MajorVersion, major), Builders.Filter.Eq(b => b.MinorVersion, minor)))
- .CountAsync();
- }
+ public async Task SelectVersionCount(uint major, uint minor) { throw new NotImplementedException(); }
}
}
\ No newline at end of file
diff --git a/BuildFeed/Models/Build/Build-Year.cs b/BuildFeed/Models/Build/Build-Year.cs
index aa2dc6f..2cdbda6 100644
--- a/BuildFeed/Models/Build/Build-Year.cs
+++ b/BuildFeed/Models/Build/Build-Year.cs
@@ -1,52 +1,19 @@
-using MongoDB.Driver;
-using System;
+using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
+using System.Web;
namespace BuildFeed.Models
{
public partial class Build
{
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectYear(int year, int skip, int limit)
- {
- return await _buildCollection.Find(b => b.BuildTime != null &&
- (b.BuildTime > new DateTime(year, 1, 1, 0, 0, 0)) &&
- (b.BuildTime < new DateTime(year, 12, 31, 23, 59, 59)))
- .SortByDescending(b => b.BuildTime)
- .ThenByDescending(b => b.MajorVersion)
- .ThenByDescending(b => b.MinorVersion)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
- }
+ public async Task SelectAllYears(int limit = -1, int skip = 0) { throw new NotImplementedException(); }
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectYears()
- {
- var result = await _buildCollection.Aggregate()
- .Match(b => b.BuildTime != null)
- .Group(b => ((DateTime)b.BuildTime).Year,
- // incoming bullshit hack
- bg => new Tuple(bg.Key))
- .SortByDescending(b => b.Item1)
- .ToListAsync();
+ public async Task SelectAllYearsCount() { throw new NotImplementedException(); }
- // work ourselves out of aforementioned bullshit hack
- return result.Select(b => b.Item1).ToList();
- }
+ public async Task> SelectYear(int year, int limit = -1, int skip = 0) { throw new NotImplementedException(); }
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task SelectYearCount(int year)
- {
- return await _buildCollection.Find(b => b.BuildTime != null &&
- (b.BuildTime > new DateTime(year, 1, 1, 0, 0, 0)) &&
- (b.BuildTime < new DateTime(year, 12, 31, 23, 59, 59)))
- .CountAsync();
- }
+ public async Task SelectYearCount(int year) { throw new NotImplementedException(); }
}
}
\ No newline at end of file
diff --git a/BuildFeed/Models/Build/Build.cs b/BuildFeed/Models/Build/Build.cs
index 1069f2d..dc8e805 100644
--- a/BuildFeed/Models/Build/Build.cs
+++ b/BuildFeed/Models/Build/Build.cs
@@ -1,133 +1,81 @@
-using MongoDB.Bson;
-using MongoDB.Driver;
-using System;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
+using MongoDB.Bson;
+using MongoDB.Driver;
namespace BuildFeed.Models
{
-
public partial class Build
{
- private const string _buildCollectionName = "builds";
-
- private MongoClient _dbClient;
- private IMongoCollection _buildCollection;
+ private const string BUILD_COLLECTION_NAME = "builds";
+ private readonly IMongoCollection _buildCollection;
+ private readonly IMongoDatabase _buildDatabase;
+ private readonly MongoClient _dbClient;
public Build()
{
- _dbClient = new MongoClient(new MongoClientSettings()
- {
- Server = new MongoServerAddress(MongoConfig.Host, MongoConfig.Port)
- });
+ _dbClient = new MongoClient
+ (new MongoClientSettings
+ {
+ Server = new MongoServerAddress(MongoConfig.Host, MongoConfig.Port)
+ });
- _buildCollection = _dbClient.GetDatabase(MongoConfig.Database).GetCollection(_buildCollectionName);
+ _buildDatabase = _dbClient.GetDatabase(MongoConfig.Database);
+ _buildCollection = _buildDatabase.GetCollection(BUILD_COLLECTION_NAME);
}
public async Task SetupIndexes()
{
var indexes = await (await _buildCollection.Indexes.ListAsync()).ToListAsync();
- if(!indexes.Any(i => i["name"] == "_idx_group"))
+ if (indexes.All(i => i["name"] != "_idx_group"))
{
- await _buildCollection.Indexes.CreateOneAsync(Builders.IndexKeys.Combine(
- Builders.IndexKeys.Descending(b => b.MajorVersion),
- Builders.IndexKeys.Descending(b => b.MinorVersion),
- Builders.IndexKeys.Descending(b => b.Number),
- Builders.IndexKeys.Descending(b => b.Revision)
- ), new CreateIndexOptions()
- {
- Name = "_idx_group"
- });
+ await _buildCollection.Indexes.CreateOneAsync
+ (Builders.IndexKeys.Combine
+ (
+ Builders.IndexKeys.Descending(b => b.MajorVersion),
+ Builders.IndexKeys.Descending(b => b.MinorVersion),
+ Builders.IndexKeys.Descending(b => b.Number),
+ Builders.IndexKeys.Descending(b => b.Revision)
+ ), new CreateIndexOptions
+ {
+ Name = "_idx_group"
+ });
}
- if (!indexes.Any(i => i["name"] == "_idx_legacy"))
+ if (indexes.All(i => i["name"] != "_idx_legacy"))
{
- await _buildCollection.Indexes.CreateOneAsync(Builders.IndexKeys.Ascending(b => b.LegacyId), new CreateIndexOptions()
- {
- Name = "_idx_legacy"
- });
+ await _buildCollection.Indexes.CreateOneAsync
+ (Builders.IndexKeys.Ascending(b => b.LegacyId), new CreateIndexOptions
+ {
+ Name = "_idx_legacy"
+ });
}
}
[DataObjectMethod(DataObjectMethodType.Select, true)]
public async Task> Select()
- {
- return await _buildCollection.Find(new BsonDocument()).ToListAsync();
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, true)]
- public async Task> SelectLatest(int limit, int skip)
{
return await _buildCollection.Find(new BsonDocument())
- .SortByDescending(b => b.Added)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, true)]
- public async Task> SelectLatestLeaked(int limit, int skip)
- {
- return await _buildCollection.Find(b => b.LeakDate != null)
- .SortByDescending(b => b.LeakDate)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
+ .ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task SelectById(Guid id)
{
- return await _buildCollection.Find(f => f.Id == id).SingleOrDefaultAsync();
+ return await _buildCollection
+ .Find(Builders.Filter.Eq(b => b.Id, id))
+ .SingleOrDefaultAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task SelectByLegacyId(long id)
{
- return await _buildCollection.Find(f => f.LegacyId == id).SingleOrDefaultAsync();
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectInBuildOrder()
- {
- return await _buildCollection.Find(new BsonDocument())
- .SortByDescending(b => b.BuildTime)
- .ThenByDescending(b => b.MajorVersion)
- .ThenByDescending(b => b.MinorVersion)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .ToListAsync();
-
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectInBuildOrder(int limit, int skip)
- {
- return await _buildCollection.Find(new BsonDocument())
- .SortByDescending(b => b.BuildTime)
- .ThenByDescending(b => b.MajorVersion)
- .ThenByDescending(b => b.MinorVersion)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
- }
-
- [DataObjectMethod(DataObjectMethodType.Select, false)]
- public async Task> SelectFlight(LevelOfFlight flight, int limit, int skip)
- {
- return await _buildCollection.Find(b => b.FlightLevel == flight)
- .SortByDescending(b => b.BuildTime)
- .ThenByDescending(b => b.MajorVersion)
- .ThenByDescending(b => b.MinorVersion)
- .ThenByDescending(b => b.Number)
- .ThenByDescending(b => b.Revision)
- .Skip(skip)
- .Limit(limit)
- .ToListAsync();
+ return await _buildCollection
+ .Find(Builders.Filter.Eq(b => b.LegacyId, id))
+ .SingleOrDefaultAsync();
}
[DataObjectMethod(DataObjectMethodType.Insert, true)]
@@ -135,19 +83,21 @@ public async Task Insert(BuildModel item)
{
item.Id = Guid.NewGuid();
item.LabUrl = item.GenerateLabUrl();
- await _buildCollection.InsertOneAsync(item);
+ await _buildCollection
+ .InsertOneAsync(item);
}
[DataObjectMethod(DataObjectMethodType.Insert, false)]
public async Task InsertAll(IEnumerable items)
{
- foreach(var item in items)
+ foreach (BuildModel item in items)
{
item.Id = Guid.NewGuid();
item.LabUrl = item.GenerateLabUrl();
}
- await _buildCollection.InsertManyAsync(items);
+ await _buildCollection
+ .InsertManyAsync(items);
}
[DataObjectMethod(DataObjectMethodType.Update, true)]
@@ -158,13 +108,15 @@ public async Task Update(BuildModel item)
item.Modified = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
item.LabUrl = item.GenerateLabUrl();
- await _buildCollection.ReplaceOneAsync(f => f.Id == item.Id, item);
+ await _buildCollection
+ .ReplaceOneAsync(Builders.Filter.Eq(b => b.Id, item.Id), item);
}
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public async Task DeleteById(Guid id)
{
- await _buildCollection.DeleteOneAsync(f => f.Id == id);
+ await _buildCollection
+ .DeleteOneAsync(Builders.Filter.Eq(b => b.Id, id));
}
}
}
\ No newline at end of file
diff --git a/BuildFeed/Models/Build/BuildGroup.cs b/BuildFeed/Models/Build/BuildGroup.cs
index bc769b6..f740942 100644
--- a/BuildFeed/Models/Build/BuildGroup.cs
+++ b/BuildFeed/Models/Build/BuildGroup.cs
@@ -7,8 +7,8 @@ public class BuildGroup
public uint Build { get; set; }
public uint? Revision { get; set; }
- public override string ToString() => Revision.HasValue ?
- $"{Major}.{Minor}.{Build}.{Revision.Value}" :
- $"{Major}.{Minor}.{Build}";
+ public override string ToString() => Revision.HasValue
+ ? $"{Major}.{Minor}.{Build}.{Revision.Value}"
+ : $"{Major}.{Minor}.{Build}";
}
}
\ No newline at end of file
diff --git a/BuildFeed/Models/Build/BuildModel.cs b/BuildFeed/Models/Build/BuildModel.cs
index 463ec25..5b90d70 100644
--- a/BuildFeed/Models/Build/BuildModel.cs
+++ b/BuildFeed/Models/Build/BuildModel.cs
@@ -1,10 +1,10 @@
-using BuildFeed.Local;
-using MongoDB.Bson.Serialization.Attributes;
-using System;
+using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text;
using System.Web.Mvc;
+using BuildFeed.Local;
+using MongoDB.Bson.Serialization.Attributes;
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
namespace BuildFeed.Models
@@ -93,13 +93,19 @@ public string FullBuildString
sb.AppendFormat("{0}.{1}.{2}", MajorVersion, MinorVersion, Number);
if (Revision.HasValue)
+ {
sb.AppendFormat(".{0}", Revision);
+ }
if (!string.IsNullOrWhiteSpace(Lab))
+ {
sb.AppendFormat(".{0}", Lab);
+ }
if (BuildTime.HasValue)
+ {
sb.AppendFormat(".{0:yyMMdd-HHmm}", BuildTime);
+ }
return sb.ToString();
}
@@ -113,47 +119,47 @@ public ProjectFamily Family
{
return ProjectFamily.Redstone;
}
- else if (Number >= 10500)
+ if (Number >= 10500)
{
return ProjectFamily.Threshold2;
}
- else if (Number >= 9700)
+ if (Number >= 9700)
{
return ProjectFamily.Threshold;
}
- else if (Number >= 9250)
+ if (Number >= 9250)
{
return ProjectFamily.Windows81;
}
- else if (Number >= 7650)
+ if (Number >= 7650)
{
return ProjectFamily.Windows8;
}
- else if (Number >= 6020)
+ if (Number >= 6020)
{
return ProjectFamily.Windows7;
}
- else if (MajorVersion == 6 && Number >= 5000)
+ if (MajorVersion == 6 && Number >= 5000)
{
return ProjectFamily.WindowsVista;
}
- else if (MajorVersion == 6)
+ if (MajorVersion == 6)
{
return ProjectFamily.Longhorn;
}
- else if (MajorVersion == 5 && Number >= 3000)
+ if (MajorVersion == 5 && Number >= 3000)
{
return ProjectFamily.Server2003;
}
- else if (MajorVersion == 5 && Number >= 2205)
+ if (MajorVersion == 5 && Number >= 2205)
{
return ProjectFamily.WindowsXP;
}
- else if (MajorVersion == 5 && MinorVersion == 50)
+ if (MajorVersion == 5 && MinorVersion == 50)
{
return ProjectFamily.Neptune;
}
- else if (MajorVersion == 5)
+ if (MajorVersion == 5)
{
return ProjectFamily.Windows2000;
}
@@ -161,6 +167,7 @@ public ProjectFamily Family
}
}
- public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-').ToLower();
+ public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-')
+ .ToLower();
}
}
\ No newline at end of file
diff --git a/BuildFeed/Models/Build/BuildVersion.cs b/BuildFeed/Models/Build/BuildVersion.cs
index 55fcc1d..ab0c8ee 100644
--- a/BuildFeed/Models/Build/BuildVersion.cs
+++ b/BuildFeed/Models/Build/BuildVersion.cs
@@ -1,6 +1,5 @@
namespace BuildFeed.Models
{
-
public struct BuildVersion
{
public uint Major { get; set; }
diff --git a/BuildFeed/Models/Build/LevelOfFlight.cs b/BuildFeed/Models/Build/LevelOfFlight.cs
index 6a6881f..63104f6 100644
--- a/BuildFeed/Models/Build/LevelOfFlight.cs
+++ b/BuildFeed/Models/Build/LevelOfFlight.cs
@@ -1,5 +1,5 @@
-using BuildFeed.Local;
-using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations;
+using BuildFeed.Local;
namespace BuildFeed.Models
{
diff --git a/BuildFeed/Models/Build/TypeOfSource.cs b/BuildFeed/Models/Build/TypeOfSource.cs
index 338cfee..aa5dc87 100644
--- a/BuildFeed/Models/Build/TypeOfSource.cs
+++ b/BuildFeed/Models/Build/TypeOfSource.cs
@@ -1,5 +1,5 @@
-using BuildFeed.Local;
-using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations;
+using BuildFeed.Local;
namespace BuildFeed.Models
{
diff --git a/BuildFeed/Models/MetaItem.cs b/BuildFeed/Models/MetaItem.cs
index b615761..cc0aff9 100644
--- a/BuildFeed/Models/MetaItem.cs
+++ b/BuildFeed/Models/MetaItem.cs
@@ -74,7 +74,7 @@ public async Task SelectById(MetaItemKey id)
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task> SelectUnusedLabs()
{
- var labs = await bModel.SelectLabs();
+ var labs = await bModel.SelectAllLabs();
var usedLabs = await _metaCollection.Find(f => f.Id.Type == MetaType.Lab).ToListAsync();
@@ -86,7 +86,7 @@ where usedLabs.All(ul => ul.Id.Value != l)
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task> SelectUnusedVersions()
{
- var versions = await bModel.SelectVersions();
+ var versions = await bModel.SelectAllVersions();
var usedVersions = await _metaCollection.Find(f => f.Id.Type == MetaType.Version).ToListAsync();
@@ -98,7 +98,7 @@ where usedVersions.All(ul => ul.Id.Value != v.ToString())
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task> SelectUnusedYears()
{
- var years = await bModel.SelectYears();
+ var years = await bModel.SelectAllYears();
var usedYears = await _metaCollection.Find(f => f.Id.Type == MetaType.Year).ToListAsync();
diff --git a/BuildFeed/Views/front/index.cshtml b/BuildFeed/Views/front/index.cshtml
index 58d5d02..dea533d 100644
--- a/BuildFeed/Views/front/index.cshtml
+++ b/BuildFeed/Views/front/index.cshtml
@@ -23,7 +23,7 @@
@foreach (BuildFeed.Models.ViewModel.Front.FrontBuildGroup group in Model)
{
-
+
@if (group.LastBuild.HasValue)
{
diff --git a/BuildFeed/Views/front/viewBuild.cshtml b/BuildFeed/Views/front/viewBuild.cshtml
index e1ccd70..a5722b0 100644
--- a/BuildFeed/Views/front/viewBuild.cshtml
+++ b/BuildFeed/Views/front/viewBuild.cshtml
@@ -37,7 +37,7 @@
@if (Roles.IsUserInRole("Administrators"))
{
- @Html.ActionLink(BuildFeed.Local.Front.Delete, "deleteBuild", new { id = Model.Id }, new { @class = "btn btn-danger btn-xs" })
+ @Html.ActionLink(BuildFeed.Local.Front.Delete, "DeleteBuild", new { id = Model.Id }, new { @class = "btn btn-danger btn-xs" })
}
@@ -82,7 +82,7 @@
else
{
@Model.Lab
- @string.Format(BuildFeed.Local.Front.MoreFromLab, Model.Lab)
+ @string.Format(BuildFeed.Local.Front.MoreFromLab, Model.Lab)
}
@@ -96,7 +96,7 @@
{
- @string.Format(BuildFeed.Local.Front.MoreFromYear, Model.BuildTime.Value.Year)
+ @string.Format(BuildFeed.Local.Front.MoreFromYear, Model.BuildTime.Value.Year)
}
@@ -110,7 +110,7 @@
@@ -172,9 +172,9 @@
diff --git a/BuildFeed/Views/front/viewGroup.cshtml b/BuildFeed/Views/front/viewGroup.cshtml
index 891da8b..5ed66eb 100644
--- a/BuildFeed/Views/front/viewGroup.cshtml
+++ b/BuildFeed/Views/front/viewGroup.cshtml
@@ -17,7 +17,7 @@
@BuildFeed.Local.Front.Edit
@if (Roles.IsUserInRole("Administrators"))
{
- @BuildFeed.Local.Front.Delete
+ @BuildFeed.Local.Front.Delete
}
}
diff --git a/BuildFeed/Views/front/viewLab.cshtml b/BuildFeed/Views/front/viewLab.cshtml
index 3864349..bad92dc 100644
--- a/BuildFeed/Views/front/viewLab.cshtml
+++ b/BuildFeed/Views/front/viewLab.cshtml
@@ -44,7 +44,7 @@
@BuildFeed.Local.Front.Edit
@if (Roles.IsUserInRole("Administrators"))
{
- @BuildFeed.Local.Front.Delete
+ @BuildFeed.Local.Front.Delete
}
}
diff --git a/BuildFeed/Views/front/viewSource.cshtml b/BuildFeed/Views/front/viewSource.cshtml
index 1bb3664..6acfb01 100644
--- a/BuildFeed/Views/front/viewSource.cshtml
+++ b/BuildFeed/Views/front/viewSource.cshtml
@@ -38,7 +38,7 @@
@BuildFeed.Local.Front.Edit
@if (Roles.IsUserInRole("Administrators"))
{
- @BuildFeed.Local.Front.Delete
+ @BuildFeed.Local.Front.Delete
}
}
diff --git a/BuildFeed/Views/front/viewVersion.cshtml b/BuildFeed/Views/front/viewVersion.cshtml
index a4797ef..fcbe448 100644
--- a/BuildFeed/Views/front/viewVersion.cshtml
+++ b/BuildFeed/Views/front/viewVersion.cshtml
@@ -38,7 +38,7 @@
@BuildFeed.Local.Front.Edit
@if (Roles.IsUserInRole("Administrators"))
{
- @BuildFeed.Local.Front.Delete
+ @BuildFeed.Local.Front.Delete
}
}
diff --git a/BuildFeed/Views/front/viewYear.cshtml b/BuildFeed/Views/front/viewYear.cshtml
index 927cb9d..7e0949f 100644
--- a/BuildFeed/Views/front/viewYear.cshtml
+++ b/BuildFeed/Views/front/viewYear.cshtml
@@ -44,7 +44,7 @@
@BuildFeed.Local.Front.Edit
@if (Roles.IsUserInRole("Administrators"))
{
- @BuildFeed.Local.Front.Delete
+ @BuildFeed.Local.Front.Delete
}
}
diff --git a/BuildFeed/Views/shared/_default.cshtml b/BuildFeed/Views/shared/_default.cshtml
index e7ad16e..0bc9630 100644
--- a/BuildFeed/Views/shared/_default.cshtml
+++ b/BuildFeed/Views/shared/_default.cshtml
@@ -60,7 +60,7 @@
- @Html.ActionLink(BuildFeed.Local.Common.SiteName, "index", new { controller = "front", area = "" }, new { @class = "navbar-brand" })
+ @Html.ActionLink(BuildFeed.Local.Common.SiteName, "Index", new { controller = "Front", area = "" }, new { @class = "navbar-brand" })
@@ -71,12 +71,12 @@
else if (Roles.IsUserInRole("Administrators"))
{
- @BuildFeed.Local.Common.Admin
- - @BuildFeed.Local.Common.AddBuild
+ - @BuildFeed.Local.Common.AddBuild
- @BuildFeed.Local.Common.LogOut
}
else
{
- - @BuildFeed.Local.Common.AddBuild
+ - @BuildFeed.Local.Common.AddBuild
- @BuildFeed.Local.Common.LogOut
}
- @BuildFeed.Local.Common.Search
diff --git a/BuildFeed/Views/shared/error.cshtml b/BuildFeed/Views/shared/error.cshtml
index cd4d8fd..1b04b27 100644
--- a/BuildFeed/Views/shared/error.cshtml
+++ b/BuildFeed/Views/shared/error.cshtml
@@ -52,7 +52,7 @@