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 @@ public ActionResult SubmitEntry(SubmitContestEntryViewModel model) 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 @@ public ActionResult CreateContest(CreateContestViewModel model) 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 }); } }