summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Project-Unite/Controllers/ManageController.cs13
-rw-r--r--Project-Unite/Views/Manage/Index.cshtml32
-rw-r--r--Project-Unite/Views/Shared/_LoginPartial.cshtml2
3 files changed, 46 insertions, 1 deletions
diff --git a/Project-Unite/Controllers/ManageController.cs b/Project-Unite/Controllers/ManageController.cs
index c3d9921..d80cbcb 100644
--- a/Project-Unite/Controllers/ManageController.cs
+++ b/Project-Unite/Controllers/ManageController.cs
@@ -111,6 +111,19 @@ namespace Project_Unite.Controllers
}
}
+ public ActionResult MarkAllRead()
+ {
+ var db = new ApplicationDbContext();
+ string uid = User.Identity.GetUserId();
+ var unread = db.Notifications.Where(x => x.IsRead == false && x.UserId == uid);
+ foreach(var u in unread.ToArray())
+ {
+ u.IsRead = true;
+ }
+ db.SaveChanges();
+ return Redirect(Url.Action("Index", "Manage") + "#t_notifications");
+ }
+
public ActionResult Notification(string id, string url)
{
var db = new ApplicationDbContext();
diff --git a/Project-Unite/Views/Manage/Index.cshtml b/Project-Unite/Views/Manage/Index.cshtml
index 198180f..cff7179 100644
--- a/Project-Unite/Views/Manage/Index.cshtml
+++ b/Project-Unite/Views/Manage/Index.cshtml
@@ -95,6 +95,38 @@
<h4>Send me notifications through email when I'm inactive</h4>
<p>Check this option to allow us to email you when you receive a notification and you haven't logged in for a week.</p> @Html.CheckBoxFor(Model=>Model.EmailOnNotifications)
+ @{
+ var notes = Model.Notifications.Where(x=>x.IsRead==false).OrderByDescending(x=>x.Timestamp);
+ }
+ <h3>Unread Notifications</h3>
+ @if (notes.Count() > 0)
+ {
+ <p>Below is a list of all unread notifications.</p>
+
+ <ul class="nav nav-tabs">
+ <li><a href="@Url.Action("MarkAllRead")"><span class="glyphicon glyphicon-book"></span> Mark all read</a></li>
+ </ul>
+
+ <div class="row">
+ <strong>Notification</strong>
+ </div>
+ @foreach(var note in notes)
+ {
+ <div class="row">
+ @if (!string.IsNullOrWhiteSpace(note.AvatarUrl))
+ {
+ <img src="@note.AvatarUrl" height="128" width="128" class="avatar" />
+ }
+ <h5>@note.Title</h5>
+ <p>@note.Description</p>
+ <a href="@note.ActionUrl" class="btn btn-default">Read</a>
+ </div>
+ }
+ }
+ else
+ {
+ <p>You have no notifications.</p>
+ }
</div>
<div class="tab-pane fade in" id="t_privacy">
<h2>Privacy &amp; Security</h2>
diff --git a/Project-Unite/Views/Shared/_LoginPartial.cshtml b/Project-Unite/Views/Shared/_LoginPartial.cshtml
index 4acf09b..2a92827 100644
--- a/Project-Unite/Views/Shared/_LoginPartial.cshtml
+++ b/Project-Unite/Views/Shared/_LoginPartial.cshtml
@@ -15,7 +15,7 @@
<ul class="dropdown-menu">
<li class="dropdown-header">Notifications (@Html.NotificationCount(User.Identity.Name) unread)</li>
@Html.GetLatestUnread(User.Identity.Name)
- <li>@Html.ActionLink("View all", "Notifications", "Manage")</li>
+ <li><a href="@Url.Action("Index", "Manage")#t_notifications">View all</a></li>
</ul>
</li>
<li class="dropdown"><a href="#" data-toggle="dropdown" class="dropdown-toggle"><span class="glyphicon glyphicon-user"></span> @Html.UserName(User.Identity.GetUserId()) <span class="caret"></span></a>