public static VMNotifications VMNotificationsFromNotifications(List <Notification> notifications) { VMNotifications vmNotifications = new VMNotifications(); vmNotifications.Notifications = new List <VMNotification>(); foreach (var n in notifications) { vmNotifications.Notifications.Add(new VMNotification(n)); } return(vmNotifications); }
public ActionResult AllNotifications(string orderBy = "TimeStamp", bool isDescending = false) { VMNotifications notifications = Translator.VMNotificationsFromNotifications(data.retrieveAllNotifications()); foreach (var n in notifications.Notifications) { n.Email = data.retrieveUser(n.UserId).Email; } notifications.IsDescending = isDescending; notifications.OrderBy = orderBy; if (isDescending) { if (orderBy == "Title") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.Title).ToList(); } else if (orderBy == "Description") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.Description).ToList(); } else if (orderBy == "TimeStamp") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.TimeStamp).ToList(); } else if (orderBy == "URL") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.URL).ToList(); } else if (orderBy == "NotificationType") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.NotificationType).ToList(); } else if (orderBy == "Seen") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.IsSeen).ToList(); } else if (orderBy == "Email") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.Email).ToList(); } else if (orderBy == "OwnerId") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.UserId).ToList(); } else if (orderBy == "Sender") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.Sender).ToList(); } else if (orderBy == "SenderId") { notifications.Notifications = notifications.Notifications.OrderByDescending(n => n.SenderId).ToList(); } } else { if (orderBy == "Title") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.Title).ToList(); } else if (orderBy == "Description") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.Description).ToList(); } else if (orderBy == "TimeStamp") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.TimeStamp).ToList(); } else if (orderBy == "URL") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.URL).ToList(); } else if (orderBy == "NotificationType") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.NotificationType).ToList(); } else if (orderBy == "Seen") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.IsSeen).ToList(); } else if (orderBy == "Email") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.Email).ToList(); } else if (orderBy == "OwnerId") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.UserId).ToList(); } else if (orderBy == "Sender") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.Sender).ToList(); } else if (orderBy == "SenderId") { notifications.Notifications = notifications.Notifications.OrderBy(n => n.SenderId).ToList(); } } return(View(model: notifications)); }