public static void CreateNotification(WebmailContext context, Notification notification, NotificationType type) { var notificationEntity = new Database.POCO.Notification() { Content = notification.Content, ContentType = notification.ContentType, CreationTime = DateTime.Now, RecipientsList = context.Users.Where(u => notification.RecipientsList.Contains(u.Email)).ToList(), Type = type, WithAttachments = notification.WithAttachments }; context.Notifications.Add(notificationEntity); context.SaveChanges(); }
public static void CreateNotification(WebmailContext context, Notification notification, DateTime?creationTime = null, NotificationType type = NotificationType.API) { var time = creationTime ?? DateTime.Now; var entity = new Database.POCO.Notification() { Content = notification.Content, ContentType = notification.ContentType, WithAttachments = notification.WithAttachments, Type = type, CreationTime = time }; context.Notifications.Add(entity); context.SaveChanges(); }
public async Task <Notification> AddAsync(Notification notification, NotificationType type) { var notificationEntity = new Database.POCO.Notification { Content = notification.Content, ContentType = notification.ContentType, WithAttachments = notification.WithAttachments, Type = type, CreationTime = DateTime.Now, RecipientsList = context.Users.Where(u => notification.RecipientsList.Contains(u.Email)).ToList(), }; var added = await context.Notifications.AddAsync(notificationEntity); await context.SaveChangesAsync(); return(new Notification(added.Entity)); }
public Notification(Database.POCO.Notification entity) { Id = entity.NotificationId; Content = entity.Content; ContentType = entity.ContentType; WithAttachments = entity.WithAttachments; CreationTime = entity.CreationTime; RecipientsList = new List <string>(); if (entity.RecipientsList == null) { return; } foreach (var user in entity.RecipientsList) { RecipientsList.Add(user.Email); } }