mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 17:22:15 +00:00
Quotes backend, sorta.
This commit is contained in:
parent
78a5e3d4b2
commit
0add14850a
2 changed files with 33 additions and 1 deletions
|
@ -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 @@ public ActionResult GetCodepoints()
|
|||
}
|
||||
}
|
||||
|
||||
public ActionResult SetCodepoints(long id)
|
||||
public ActionResult SetCodepoints(ulong id)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -225,6 +225,15 @@ public UserFollow[] Followers
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ public static ApplicationDbContext Create()
|
|||
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; }
|
||||
|
|
Loading…
Reference in a new issue