Ejemplo n.º 1
0
 // .........................................................................Submit Added List Item Emails To Queue.....................................................................
 private void SubmitAddedListItemEmailsToQueue(EmailParams emailParams)
 {
     emailService.AddToQueue(EmailType.AddedListItem, "An item has been added to your list", emailParams.Recipients, new EmailProperties
     {
         Host    = emailParams.Host,
         Product = emailParams.Product,
         Link    = emailParams.Host + "/account/lists/" + emailParams.List.Id,
         Person  = emailParams.Collaborator,
         Var1    = emailParams.List.Name
     });
 }
Ejemplo n.º 2
0
        // .........................................................................Setup Added List Item Email.....................................................................
        private async Task SetupAddedListItemEmail(NicheShackContext context, object state)
        {
            EmailSetupParams emailSetupParams = (EmailSetupParams)state;

            List <string> recipientIds = await GetRecipientIds(context, EmailType.AddedListItem, emailSetupParams.ListId1, emailSetupParams.CustomerId);

            EmailParams emailParams = await GetEmailParams(context, emailSetupParams.CustomerId, emailSetupParams.ListId1, emailSetupParams.Host, recipientIds, emailSetupParams.ProductId);

            if (emailParams == null)
            {
                return;
            }


            // Add emails to the queue
            SubmitAddedListItemEmailsToQueue(emailParams);
        }
Ejemplo n.º 3
0
        // .........................................................................Setup Added Collaborator Email.....................................................................
        private async Task SetupAddedCollaboratorEmail(NicheShackContext context, object state)
        {
            EmailSetupParams emailSetupParams = (EmailSetupParams)state;

            List <string> recipientIds = await GetRecipientIds(context, EmailType.NewCollaborator, emailSetupParams.ListId1, emailSetupParams.CustomerId);

            EmailParams emailParams = await GetEmailParams(context, emailSetupParams.CustomerId, emailSetupParams.ListId1, emailSetupParams.Host, recipientIds);

            if (emailParams == null)
            {
                return;
            }


            emailService.AddToQueue(EmailType.NewCollaborator, "A new Collaborator has joined your list", emailParams.Recipients, new EmailProperties
            {
                Host   = emailParams.Host,
                Link   = emailParams.Host + "/account/lists/" + emailParams.List.Id,
                Person = emailParams.Collaborator,
                Var1   = emailParams.List.Name
            });
        }
Ejemplo n.º 4
0
        // .........................................................................Setup Changed List Name.....................................................................
        private async Task SetupChangedListName(NicheShackContext context, object state)
        {
            EmailSetupParams emailSetupParams = (EmailSetupParams)state;

            List <string> recipientIds = await GetRecipientIds(context, EmailType.ListNameChange, emailSetupParams.ListId1, emailSetupParams.CustomerId);

            EmailParams emailParams = await GetEmailParams(context, emailSetupParams.CustomerId, emailSetupParams.ListId1, emailSetupParams.Host, recipientIds);

            if (emailParams == null)
            {
                return;
            }


            // Add email to queue
            emailService.AddToQueue(EmailType.ListNameChange, "List name changed", emailParams.Recipients, new EmailProperties
            {
                Host   = emailSetupParams.Host,
                Var1   = emailSetupParams.Var1,
                Var2   = emailSetupParams.Var2,
                Person = emailParams.Collaborator
            });
        }
Ejemplo n.º 5
0
        // .........................................................................Send Moved List Item Email.....................................................................
        private async Task SetupMovedListItemEmail(NicheShackContext context, object state)
        {
            EmailSetupParams emailSetupParams = (EmailSetupParams)state;


            List <string> fromListCustomerIds = await context.ListCollaborators
                                                .AsNoTracking()
                                                .Where(x => x.ListId == emailSetupParams.ListId1 && !x.IsRemoved && x.CustomerId != emailSetupParams.CustomerId && x.Customer.EmailPrefMovedListItem == true)
                                                .Select(x => x.CustomerId)
                                                .ToListAsync();

            List <string> bothListRecipientIds = await context.ListCollaborators
                                                 .AsNoTracking()
                                                 .Where(x => x.ListId == emailSetupParams.ListId2 && !x.IsRemoved && x.CustomerId != emailSetupParams.CustomerId && fromListCustomerIds.Contains(x.CustomerId) && x.Customer.EmailPrefMovedListItem == true)
                                                 .Select(x => x.CustomerId)
                                                 .ToListAsync();

            if (bothListRecipientIds.Count > 0)
            {
                EmailParams bothListEmailParams = await GetEmailParams(context, emailSetupParams.CustomerId, emailSetupParams.ListId2, emailSetupParams.Host, bothListRecipientIds, emailSetupParams.ProductId);

                string fromListName = await context.Lists
                                      .AsNoTracking()
                                      .Where(x => x.Id == emailSetupParams.ListId1)
                                      .Select(x => x.Name)
                                      .SingleAsync();

                emailService.AddToQueue(EmailType.MovedListItem, "An item has been moved to another list", bothListEmailParams.Recipients, new EmailProperties
                {
                    Host    = bothListEmailParams.Host,
                    Product = bothListEmailParams.Product,
                    Link    = bothListEmailParams.Host + "/account/lists/" + bothListEmailParams.List.Id,
                    Person  = bothListEmailParams.Collaborator,
                    Var1    = fromListName,
                    Var2    = bothListEmailParams.List.Name
                });
            }


            List <string> fromListRecipientIds = await GetRecipientIds(context, EmailType.RemovedListItem, emailSetupParams.ListId1, emailSetupParams.CustomerId);

            fromListRecipientIds = fromListRecipientIds.Where(x => !bothListRecipientIds.Contains(x)).ToList();

            if (fromListRecipientIds.Count > 0)
            {
                EmailParams fromListEmailParams = await GetEmailParams(context, emailSetupParams.CustomerId, emailSetupParams.ListId1, emailSetupParams.Host, fromListRecipientIds, emailSetupParams.ProductId);

                SubmitRemovedListItemEmailsToQueue(fromListEmailParams);
            }



            List <string> toListRecipientIds = await GetRecipientIds(context, EmailType.AddedListItem, emailSetupParams.ListId2, emailSetupParams.CustomerId);

            toListRecipientIds = toListRecipientIds.Where(x => !bothListRecipientIds.Contains(x)).ToList();

            if (toListRecipientIds.Count > 0)
            {
                EmailParams toListEmailParams = await GetEmailParams(context, emailSetupParams.CustomerId, emailSetupParams.ListId2, emailSetupParams.Host, toListRecipientIds, emailSetupParams.ProductId);

                SubmitAddedListItemEmailsToQueue(toListEmailParams);
            }
        }