summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-21 09:33:48 -0400
committerMichael <[email protected]>2017-05-21 09:33:48 -0400
commita2eed3b184cfacf2319ae259292915a72ddbb839 (patch)
tree68d4bdd37f4c651cb855db72c4c2cb6f2671a7c0
parent54f52b10a64b564aef489310da29b12d64c4ec18 (diff)
downloadproject-unite-a2eed3b184cfacf2319ae259292915a72ddbb839.tar.gz
project-unite-a2eed3b184cfacf2319ae259292915a72ddbb839.tar.bz2
project-unite-a2eed3b184cfacf2319ae259292915a72ddbb839.zip
notify users when certain contest events happen
-rw-r--r--Project-Unite/Controllers/ContestsController.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/ContestsController.cs b/Project-Unite/Controllers/ContestsController.cs
index b4315d3..8cdb229 100644
--- a/Project-Unite/Controllers/ContestsController.cs
+++ b/Project-Unite/Controllers/ContestsController.cs
@@ -111,6 +111,15 @@ namespace Project_Unite.Controllers
db.ContestEntries.Add(entry);
db.SaveChanges();
+
+ foreach(var user in db.Users.ToArray())
+ {
+ if (user.HighestRole.IsAdmin)
+ {
+ NotificationDaemon.NotifyUser(entry.AuthorId, user.Id, "New contest entry!", "A new entry has been submitted to the \"" + db.Contests.FirstOrDefault(x=>x.Id==entry.ContestId).Name + "\" contest.", Url.Action("ViewSubmission", "Contests", new { id = entry.Id }));
+ }
+ }
+
return RedirectToAction("ViewSubmission", "Contests", new { id = entry.Id });
}
@@ -152,6 +161,8 @@ namespace Project_Unite.Controllers
db.Contests.Add(c);
db.SaveChanges();
+ NotificationDaemon.NotifyEveryone(User.Identity.GetUserId(), "A contest has just started.", "A new contest has been open! Contest: " + c.Name, Url.Action("ViewContest", new { id = c.Id }));
+
return RedirectToAction("ViewContest", new { id = c.Id });
}
}