public bool AddNotification(NotificationTypeMap notificationType, long contentId, long userId, long subDirectoryId, string notifierName) { var notificationTypeObj = GetNotificationTypeFromEnum(notificationType); if (notificationTypeObj != null) { var notification = new Notification() { ContentId = contentId, NotificationTypeId = notificationTypeObj.Id, Timestamp = DateTime.Now, SubDirectoryId = subDirectoryId }; AddNotificationMessageText(notification, notificationType, notifierName); _notificationRepository.Add(notification); return(Convert.ToBoolean(_notificationRepository.Save())); } return(false); }
public void AddNotificationMessageText(Notification notification, NotificationTypeMap notificationType, string notifierName) { var message = string.Empty; switch (notificationType) { case NotificationTypeMap.Like: message = $"User {notifierName} upvoted your comment"; break; case NotificationTypeMap.Mention: message = $"User {notifierName} mentioned you"; break; case NotificationTypeMap.Rate: message = $"User {notifierName} rated your content"; break; case NotificationTypeMap.Reply: message = $"User {notifierName} replied to your comment"; break; case NotificationTypeMap.Tip: message = $"User {notifierName} tipped you"; break; case NotificationTypeMap.Report: message = $"Somebody reported your content"; break; case NotificationTypeMap.ValidatedContent: message = $"You got paid {notifierName} for validating content"; break; } notification.NotificationText = message; }
public NotificationType GetNotificationTypeFromEnum(NotificationTypeMap notificationType) { return(_notificationTypeRepository.GetAll() .FirstOrDefault(x => x.TypeName == notificationType.ToString())); }