diff --git a/BuildFeed.Model/Api/ApiBuild.cs b/BuildFeed.Model/Api/ApiBuild.cs new file mode 100644 index 0000000..32b645d --- /dev/null +++ b/BuildFeed.Model/Api/ApiBuild.cs @@ -0,0 +1,21 @@ +using System; + +namespace BuildFeed.Model.Api +{ + public class ApiBuild : BuildDetails + { + public Guid Id { get; set; } + + public string FullBuildString { get; set; } + + public string AlternateBuildString { get; set; } + + public string LabUrl { get; set; } + + public bool IsLeaked => SourceType == TypeOfSource.PublicRelease || SourceType == TypeOfSource.InternalLeak || SourceType == TypeOfSource.UpdateGDR; + + public DateTime Added { get; set; } + + public DateTime Modified { get; set; } + } +} \ No newline at end of file diff --git a/BuildFeed.Model/BuildFeed.Model.csproj b/BuildFeed.Model/BuildFeed.Model.csproj index 480b6d3..08c2889 100644 --- a/BuildFeed.Model/BuildFeed.Model.csproj +++ b/BuildFeed.Model/BuildFeed.Model.csproj @@ -89,6 +89,7 @@ + diff --git a/BuildFeed/Controllers/apiController.cs b/BuildFeed/Controllers/apiController.cs index 8a920e7..7be73ff 100644 --- a/BuildFeed/Controllers/apiController.cs +++ b/BuildFeed/Controllers/apiController.cs @@ -25,10 +25,33 @@ public ApiController() _bModel = new BuildRepository(); } - public async Task GetBuilds(int limit = 20, int skip = 0) + public async Task GetBuilds(int limit = 20, int skip = 0) { List builds = await _bModel.SelectBuildsByOrder(limit, skip); - return builds.ToArray(); + return (from b in builds + select new ApiBuild + { + Id = b.Id, + + MajorVersion = b.MajorVersion, + MinorVersion = b.MinorVersion, + Number = b.Number, + Revision = b.Revision, + + Lab = b.Lab, + BuildTime = b.BuildTime, + + SourceType = b.SourceType, + SourceDetails = b.SourceDetails, + LeakDate = b.LeakDate, + + FullBuildString = b.FullBuildString, + AlternateBuildString = b.AlternateBuildString, + LabUrl = b.LabUrl, + + Added = b.Added, + Modified = b.Modified + }).ToArray(); } public async Task GetBuildGroups(int limit = 20, int skip = 0) @@ -37,7 +60,7 @@ public async Task GetBuildGroups(int limit = 20, int skip = 0 return bgroups.ToArray(); } - public async Task GetBuildsForBuildGroup(uint major, uint minor, uint number, uint? revision = null) + public async Task GetBuildsForBuildGroup(uint major, uint minor, uint number, uint? revision = null) { List builds = await _bModel.SelectGroup(new BuildGroup { @@ -47,13 +70,60 @@ public async Task GetBuildsForBuildGroup(uint major, uint minor, uint n Revision = revision }); - return builds.ToArray(); + return (from b in builds + select new ApiBuild + { + Id = b.Id, + + MajorVersion = b.MajorVersion, + MinorVersion = b.MinorVersion, + Number = b.Number, + Revision = b.Revision, + + Lab = b.Lab, + BuildTime = b.BuildTime, + + SourceType = b.SourceType, + SourceDetails = b.SourceDetails, + LeakDate = b.LeakDate, + + FullBuildString = b.FullBuildString, + AlternateBuildString = b.AlternateBuildString, + LabUrl = b.LabUrl, + + Added = b.Added, + Modified = b.Modified + }).ToArray(); } - public async Task GetBuildsByLab(string lab, int limit = 20, int skip = 0) + public async Task GetBuildsByLab(string lab, int limit = 20, int skip = 0) { List builds = await _bModel.SelectLab(lab, limit, skip); - return builds.ToArray(); + + return (from b in builds + select new ApiBuild + { + Id = b.Id, + + MajorVersion = b.MajorVersion, + MinorVersion = b.MinorVersion, + Number = b.Number, + Revision = b.Revision, + + Lab = b.Lab, + BuildTime = b.BuildTime, + + SourceType = b.SourceType, + SourceDetails = b.SourceDetails, + LeakDate = b.LeakDate, + + FullBuildString = b.FullBuildString, + AlternateBuildString = b.AlternateBuildString, + LabUrl = b.LabUrl, + + Added = b.Added, + Modified = b.Modified + }).ToArray(); } public async Task> GetWin10Labs() diff --git a/BuildFeed/Web.config b/BuildFeed/Web.config index c7f8432..a5522d9 100644 --- a/BuildFeed/Web.config +++ b/BuildFeed/Web.config @@ -11,7 +11,7 @@ - +