public ActionResult Show(Guid id, Guid componentId) { var storageContext = CurrentAccountDbContext; var notificationRepository = storageContext.GetNotificationRepository(); var notification = notificationRepository.Find(id, componentId); if (!CurrentUser.CanManageAccount() && CurrentUser.Id != notification.UserId) { throw new NoAccessToPageException(); } var userRepository = CurrentAccountDbContext.GetUserRepository(); var user = userRepository.GetById(notification.UserId); var subscriptionRepository = CurrentAccountDbContext.GetSubscriptionRepository(); var subscription = notification.SubscriptionId.HasValue ? subscriptionRepository.GetById(notification.SubscriptionId.Value) : null; var model = new NotificationDetailsModel() { Id = notification.Id, Channel = notification.Type, CreationDate = notification.CreationDate, Event = notification.Event, SendDate = notification.SendDate, SendError = notification.SendError, Status = notification.Status, Subscription = subscription, User = user, Address = notification.Address }; return(View(model)); }
//[ActionName("GetUserNotifications")] public HttpResponseMessage GetUserNotifications(int UserId) { var userNotifications = _db.UserNotifications.Where(a => a.UserId == UserId); NotificationModel _Notification = new NotificationModel(); _Notification.MESSAGE = "User Notifications"; _Notification.Flag = "false"; List <NotificationDetailsModel> _lstNotificationDetails = new List <NotificationDetailsModel>(); if (null != userNotifications) { _Notification.Flag = "true"; foreach (var noti in userNotifications) { NotificationDetailsModel _NotificationModel = new NotificationDetailsModel(); var _NotificationDetail = _db.Notifications.FirstOrDefault(b => b.NotificationId == noti.NotificationId && noti.Status != Status.Deleted.ToString()); if (null != _NotificationDetail) { _NotificationModel.NotificationId = _NotificationDetail.NotificationId; _NotificationModel.Title = "" + _NotificationDetail.Title; _NotificationModel.Description = "" + _NotificationDetail.Description; _NotificationModel.NotificationType = "" + _NotificationDetail.NotificationType; _NotificationModel.Status = "" + noti.Status; _NotificationModel.NotificationReceived = TimeAgo(noti.ReceivedDate); _lstNotificationDetails.Add(_NotificationModel); } } } _Notification.lstNotifications = _lstNotificationDetails; return(Request.CreateResponse(HttpStatusCode.OK, _Notification)); }