Basic API for adding builds

That'll be starting on #4
This commit is contained in:
Thomas Hounsell 2015-05-18 22:22:42 +01:00
parent 56a8613315
commit 2ccf7b5dbe
3 changed files with 35 additions and 0 deletions

View File

@ -179,6 +179,7 @@
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Models\ApiModel\NewBuild.cs" />
<Compile Include="Models\ApiModel\SearchResult.cs" />
<Compile Include="Models\Build.cs" />
<Compile Include="Models\MetaItem.cs" />

View File

@ -6,6 +6,7 @@
using System.Web.Http;
using BuildFeed.Models;
using BuildFeed.Models.ApiModel;
using System.Web.Security;
namespace BuildFeed.Controllers
{
@ -25,6 +26,24 @@ public IEnumerable<string> GetWin10Labs()
return labs.GroupBy(l => l).Select(l => l.Key).ToArray();
}
[HttpPost]
public bool AddWin10Builds(NewBuild apiModel)
{
if (apiModel == null)
{
return false;
}
if (Membership.ValidateUser(apiModel.Username, apiModel.Password))
{
Build.InsertAll(apiModel.NewBuilds);
return true;
}
else
{
return false;
}
}
public IEnumerable<SearchResult> GetSearchResult(string query)
{
if (string.IsNullOrWhiteSpace(query))

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace BuildFeed.Models.ApiModel
{
public class NewBuild
{
public string Username { get; set; }
public string Password { get; set; }
public Build[] NewBuilds { get; set; }
}
}