notify users when certain contest events happen

This commit is contained in:
Michael 2017-05-21 09:33:48 -04:00
parent 54f52b10a6
commit a2eed3b184

View file

@ -111,6 +111,15 @@ public ActionResult SubmitEntry(SubmitContestEntryViewModel model)
db.ContestEntries.Add(entry); db.ContestEntries.Add(entry);
db.SaveChanges(); 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 }); return RedirectToAction("ViewSubmission", "Contests", new { id = entry.Id });
} }
@ -152,6 +161,8 @@ public ActionResult CreateContest(CreateContestViewModel model)
db.Contests.Add(c); db.Contests.Add(c);
db.SaveChanges(); 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 }); return RedirectToAction("ViewContest", new { id = c.Id });
} }
} }