public static void CreateUser(WebmailContext context, User user) { var entity = new Database.POCO.User() { Email = user.Email, FirstName = user.FirstName, LastName = user.LastName, Role = user.Role }; context.Users.Add(entity); context.SaveChanges(); }
public static Group CreateGroup(WebmailContext context, string name, Database.POCO.User admin, List <Database.POCO.User> members = null) { var group = new Database.POCO.Group() { Name = name, Admin = admin, Users = members ?? new List <Database.POCO.User>() }; context.Groups.Add(group); context.SaveChanges(); return(CreateGroup(group)); }
public static Database.POCO.User CreateUser(WebmailContext context, string email, Role role = Role.USER, string firstName = "Mariusz", string lastName = "Tester") { var entity = new Database.POCO.User() { Email = email, FirstName = firstName, LastName = lastName, Role = role }; context.Users.Add(entity); context.SaveChanges(); return(entity); }
public static Database.POCO.User CreateTestUser(WebmailContext context, Role role = Role.USER, string email = "*****@*****.**") { var user = new Database.POCO.User() { Email = email, FirstName = "Mariusz", LastName = "Tester", Role = role }; context.Users.Add(user); context.SaveChanges(); return(user); }
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 static Database.POCO.Message CreateMessage(WebmailContext context, string subject, string content, Database.POCO.User sender, List <Database.POCO.User> receivers, List <Database.POCO.User> cc, List <Database.POCO.User> bcc, DateTime?receivedTime = null) { var message = new Database.POCO.Message() { Sender = sender, Subject = subject, MessageBody = content, Attachments = new List <Database.POCO.Attachment>(), ReceivedTime = receivedTime ?? DateTime.Now }; message.MessagesReceivers = receivers.Select(mr => new MessagesReceivers() { User = mr, Message = message, IsRead = false }).ToList(); message.MessagesCCs = cc.Select(mc => new MessagesCCs() { User = mc, Message = message, IsRead = false }).ToList(); message.MessagesBCCs = bcc.Select(mb => new MessagesBCCs() { User = mb, Message = message, IsRead = false }).ToList(); message = context.Messages.Add(message).Entity; context.SaveChanges(); return(message); }