diff options
| author | Michael <[email protected]> | 2017-05-30 17:34:15 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-30 17:34:15 -0400 |
| commit | 0add14850adff48d3421d2527d8e40b18b606131 (patch) | |
| tree | 68118a51daeb7d4ab281fcfd24588462c526266d | |
| parent | 78a5e3d4b22299b2ae3b95bada43e556b79c0bdf (diff) | |
| download | project-unite-0add14850adff48d3421d2527d8e40b18b606131.tar.gz project-unite-0add14850adff48d3421d2527d8e40b18b606131.tar.bz2 project-unite-0add14850adff48d3421d2527d8e40b18b606131.zip | |
Quotes backend, sorta.
| -rw-r--r-- | Project-Unite/Controllers/APIController.cs | 24 | ||||
| -rw-r--r-- | Project-Unite/Models/IdentityModels.cs | 10 |
2 files changed, 33 insertions, 1 deletions
diff --git a/Project-Unite/Controllers/APIController.cs b/Project-Unite/Controllers/APIController.cs index f225c68..925fb90 100644 --- a/Project-Unite/Controllers/APIController.cs +++ b/Project-Unite/Controllers/APIController.cs @@ -12,6 +12,28 @@ namespace Project_Unite.Controllers { public class APIController : Controller { + public ActionResult GetRandomQuote() + { + var db = new ApplicationDbContext(); + var quotes = db.Quotes.ToArray(); + if (quotes.Length == 0) + { + return Content(Serializer.Serialize(new Quote + { + Id = "DEADDEAD", + AuthorAvatar = "", + AuthorId = "No data.", + Body = "There is no quote data on http://getshiftos.ml/. Please submit some quotes!", + Year = 8675309 + })); + } + else + { + var rnd = new Random(); + return Content(Serializer.Serialize(quotes[rnd.Next(0, quotes.Length)])); + } + } + public ActionResult GetPongCP() { try @@ -103,7 +125,7 @@ namespace Project_Unite.Controllers } } - public ActionResult SetCodepoints(long id) + public ActionResult SetCodepoints(ulong id) { try { diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs index 1b87197..86de44d 100644 --- a/Project-Unite/Models/IdentityModels.cs +++ b/Project-Unite/Models/IdentityModels.cs @@ -225,6 +225,15 @@ namespace Project_Unite.Models } } + public class Quote + { + public string Id { get; set; } + public string AuthorId { get; set; } + public string Body { get; set; } + public string AuthorAvatar { get; set; } + public long Year { get; set; } + } + public class BannedIP { public string Id { get; set; } @@ -254,6 +263,7 @@ namespace Project_Unite.Models return new ApplicationDbContext(); } + public DbSet<Quote> Quotes { get; set; } public DbSet<Contest> Contests { get; set; } public DbSet<ContestEntry> ContestEntries { get; set; } public DbSet<Bug> Bugs { get; set; } |
