Ejemplo n.º 1
0
        public async Task <Group> AddAsync(Group group)
        {
            var groupEntity = new Database.POCO.Group()
            {
                Name  = group.Name,
                Admin = context.Users.First(u => u.Email.Equals(group.Admin.Email)),
                Users = findMembers(group).ToList()
            };

            var added = context.Groups.Add(groupEntity).Entity;
            await context.SaveChangesAsync();

            return(createGroup(added));
        }
Ejemplo n.º 2
0
        public async Task <Attachment> AddAsync(Attachment attachment)
        {
            var attachmentEntity = new Database.POCO.Attachment()
            {
                Filename  = attachment.Filename,
                Url       = attachment.Url,
                MessageId = attachment.Message.Id
            };

            context.Attachments.Add(attachmentEntity);
            await context.SaveChangesAsync();

            return(attachment);
        }
Ejemplo n.º 3
0
        public async Task <User> AddAsync(User user)
        {
            var userEntity = new Database.POCO.User()
            {
                FirstName = user.FirstName,
                LastName  = user.LastName,
                Email     = user.Email,
                Role      = user.Role
            };

            context.Users.Add(userEntity);
            await context.SaveChangesAsync();

            return(user);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        public async Task <Message> AddAsync(Message message)
        {
            var messageEntity = new Database.POCO.Message()
            {
                Subject           = message.Subject,
                MessageBody       = message.MessageBody,
                Sender            = context.Users.First(u => u.Email.Equals(message.Sender.Email)),
                MessagesReceivers = findReceivers(message).ToList(),
                MessagesCCs       = findCC(message).ToList(),
                MessagesBCCs      = findBCC(message).ToList(),
                Attachments       = findAttachments(message).ToList(),
                ReceivedTime      = message.ReceivedTime
            };

            var added = context.Messages.Add(messageEntity).Entity;
            await context.SaveChangesAsync();

            return(createMessage(added));
        }