public void UpdateCustomerInfoRemoveTest_RemovesCustomer()
        {
            Customers customer = new Customers(firstName, lastName, type);
            EmailRepo repo     = new EmailRepo();

            repo.CreateCustomer(customer);
            Assert.IsTrue(repo.UpdateCustomerInfo(customer, "4", ""));
            Assert.IsFalse(repo.ShowCustomers());
        }
        public void UpdateCustomerInfoLastNameTest_UpdatesLastName()
        {
            Customers customer = new Customers(firstName, lastName, type);
            EmailRepo repo     = new EmailRepo();

            repo.CreateCustomer(customer);
            Assert.IsTrue(repo.UpdateCustomerInfo(customer, "2", "Lucus"));
            Assert.IsTrue(repo.ShowCustomers());
        }
        public void UpdateCustomerInfoTypeTest_UpdatesType()
        {
            Customers customer = new Customers(firstName, lastName, type);
            EmailRepo repo     = new EmailRepo();

            repo.CreateCustomer(customer);
            Assert.IsTrue(repo.UpdateCustomerInfo(customer, "3", "potential"));
            Assert.IsTrue(repo.ShowCustomers());
        }
        public void CreateAndShowCustomersTest_AddCustomerToListAndShow()
        {
            Customers customer = new Customers(firstName, lastName, type);
            EmailRepo repo     = new EmailRepo();

            repo.CreateCustomer(customer);
            repo.CreateCustomer(customer);
            Assert.IsTrue(repo.ShowCustomers());
        }
Пример #5
0
        public string GetEmailBody(int EmailId)
        {
            EmailRepo repo      = new EmailRepo();
            var       emailData = repo.GetEmailBody(EmailId);

            if (emailData == null)
            {
                return(string.Empty);
            }
            return(string.IsNullOrEmpty(emailData.HTML) ? emailData.Text : emailData.HTML);
        }
Пример #6
0
        public static int SendFailedReceipts()
        {
            var failed = EmailRepo.Email_EnrollmentFailure_GetAll();

            foreach (var item in failed)
            {
                var e        = new Enrollment(item.Master_enrollment_id.GetValueOrDefault());
                var response = e.SendEnrollmentReceipt(item.Type.GetValueOrDefault(), false);

                if (response.Message == "Success")
                {
                    EmailRepo.Emaill_EnrollmentFailure_Delete(item.ID);
                }
            }
            return(1);
        }
Пример #7
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                logger.Debug("email message processing");
                string            emailBaseFolder = AppSettingsHelper.GetValueFromAppSettings(Common.Enums.AppSettingsKey.hmailServerEmailBaseFolder);
                List <string>     emailFiles      = Directory.GetFiles(emailBaseFolder, "*.eml", SearchOption.AllDirectories).ToList();
                ImageCopySettings settings        = new ImageCopySettings();
                EmailRepo         repo            = new EmailRepo();
                PublisherRepo     publisherRepo   = new PublisherRepo();
                foreach (var email in emailFiles)
                {
                    try
                    {
                        CDO.Message message = ReadMessage(email);

                        int    publisherId = GetPublisherIdFromEmail(message);
                        string emailHTML   = ChangeImgSrcToLocal(message.HTMLBody, settings, publisherId);
                        repo.AddEmail(new Common.Models.Email()
                        {
                            EmailHeaders  = GetEmailHeaders(message),
                            HTML          = emailHTML,
                            HTMLText      = emailHTML,
                            ReceivedGMT   = message.ReceivedTime.ToUniversalTime(),
                            SenderAddress = message.From,
                            SenderName    = message.Sender,
                            SubjectLine   = message.Subject,
                            Text          = message.TextBody,
                            PublisherID   = publisherId,
                            Copy          = message.CC
                        });
                        File.Delete(email);
                        publisherRepo.UpdateLastReceivedEmailDate(publisherId);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
Пример #8
0
        public List <Email> GetEmails(int start, int length, string searchCriteria, int publisherID, string from, string to, List <Common.Models.SortColumn> sorting, bool addPublisherName = false)
        {
            EmailRepo repo   = new EmailRepo();
            var       result = Map(repo.GetPublisherEmails(start, length, searchCriteria, publisherID, GetDate(from), GetDate(to), sorting));

            if (addPublisherName)
            {
                var             publisherIds = result.Select(x => x.PublisherID).ToList();
                PublisherHelper helper       = new PublisherHelper();
                var             publishers   = helper.GetPublishersName(publisherIds);
                foreach (var item in result)
                {
                    var emailPublisher = publishers.FirstOrDefault(x => x.ID == item.PublisherID);
                    if (emailPublisher != null)
                    {
                        item.PublisherName = emailPublisher.Name;
                    }
                }
            }
            return(result);
        }
Пример #9
0
        public RegisterModel(
            UserManager <IdentityUser> userManager,
            SignInManager <IdentityUser> signInManager,
            ILogger <RegisterModel> logger,
            IEmailSender emailSender,
            PlateTimeContext context,
            IServiceProvider serviceProvider,
            IOptions <EmailSettings> emailSettings,
            IConfiguration configuration)
        {
            _userManager     = userManager;
            _signInManager   = signInManager;
            _logger          = logger;
            _emailSender     = emailSender;
            _context         = context;
            _serviceProvider = serviceProvider;
            _configuration   = configuration;

            _emailSettings = emailSettings.Value;
            emailRepo      = new EmailRepo(_emailSettings);

            //emailRepo.SendMail("*****@*****.**", "hello from platetime", @"<p>Thanks for signing up.<p>");
        }
Пример #10
0
        public int GetTotalRecords(int publisherID)
        {
            EmailRepo repo = new EmailRepo();

            return(repo.GetTotalRecords(publisherID));
        }
Пример #11
0
        public Email GetFirstPublisherEmail(PublisherStatus status, int publisherId)
        {
            EmailRepo repo = new EmailRepo();

            return(Map(repo.GetFirstPublisherEmail(status, publisherId)));
        }
Пример #12
0
        public Email GetPrevEmailByPublisherCountryAndStatus(string countryCode, PublisherStatus status, int publisherId)
        {
            EmailRepo repo = new EmailRepo();

            return(Map(repo.GetPrevEmailByPublisherCountryAndStatus(countryCode, status, publisherId), countryCode));
        }
Пример #13
0
        public Email GetEmail(int emailID)
        {
            EmailRepo repo = new EmailRepo();

            return(Map(repo.Get(emailID)));
        }
Пример #14
0
        public Email GetEmailByPublisherCountryAndStatus(string countryCode, PublisherStatus status)
        {
            EmailRepo repo = new EmailRepo();

            return(Map(repo.GetEmailByPublisherCountryAndStatus(countryCode, status), countryCode));;
        }
Пример #15
0
        public int GetTotalFilteredRecords(string searchText, int publisherID, string from, string to)
        {
            EmailRepo repo = new EmailRepo();

            return(repo.GetTotalFilteredRecords(searchText, publisherID, GetDate(from), GetDate(to)));
        }
Пример #16
0
        public async Task <IHttpActionResult> CreateUser(
            CreateUserBindingModel createUserModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Email confirmEmail = new Email();

            var existingUser
                = await this.AppUserManager
                  .FindByEmailAsync(createUserModel.Email.ToLower());

            if (existingUser != null)
            {
                // 注册邮件存在
                //return BadRequest(ModelState);
                return(BadRequest(createUserModel.Email + " - the email has registered !"));
            }

            var user = new ApplicationUser()
            {
                UserName  = createUserModel.Username,
                Email     = createUserModel.Email,
                FirstName = createUserModel.FirstName,
                LastName  = createUserModel.LastName,
                Level     = 3,
                JoinDate  = DateTime.Now.Date,
            };

            IdentityResult addUserResult =
                await this.AppUserManager.CreateAsync(user, createUserModel.Password);

            if (!addUserResult.Succeeded)
            {
                return(GetErrorResult(addUserResult));
            }

            string code = await this.AppUserManager.GenerateEmailConfirmationTokenAsync(user.Id);

            var callbackUrl = new Uri(Url.Link("ConfirmEmailRoute",
                                               new { userId = user.Id, code = code }));

            await this.AppUserManager.SendEmailAsync(user.Id, "Confirm your account",
                                                     "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

            Uri locationHeader = new Uri(Url.Link("GetUserById", new { id = user.Id }));

            //Send confirm email by sendgrid.....
            string emailStr = "<h3>" + user.FirstName + "</h3>" + "<p>Please confirm your account by clicking this link: <a href=\""
                              + callbackUrl + "\">Confirm Registration</a></p>";

            confirmEmail.FromAddress = "Ming from SendGrid";
            confirmEmail.ToAddress   = user.Email;
            confirmEmail.Message     = emailStr;
            confirmEmail.Subject     = "Register Confirm Email";

            EmailRepo.SendEmail(confirmEmail);

            // From this result and as good practice we should return the resource created in the location header
            // and return 201 created status.??

            return(Created(locationHeader, TheModelFactory.Create(user)));
        }