Esempio n. 1
0
        public ActionResult ContactUs(ContactUsViewModel model)
        {
            var encodedResponse = Request.Form[RecaptchaResult.ResponseFormVariable];
            var isCaptchaValid  = _recaptchaService.Validate(encodedResponse);

            if (!isCaptchaValid)
            {
                ModelState.AddModelError("", Dictionary.InvalidRecaptcha);
                return(View("ContactUs", model));
            }

            try
            {
                _mailer.SendEmail(
                    model.Subject,
                    model.Body,
                    _config.SupportEmailAddress,
                    _config.CompanyName,
                    model.EmailAddress,
                    model.Name);

                var contact = _contactService.GetOrCreateContact("", model.Name, model.EmailAddress);
                SendEmailToCustomer(contact);

                return(RedirectToAction("ContactUsSuccess"));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.GetFullErrorMessage());
                return(View("FriendlyError"));
            }
        }
Esempio n. 2
0
        public ActionResult Registration(RegistrationCommand command)
        {
            var message = string.Empty;

            if (_profileCondition.ValidateEmail(command.user_email))
            {
                if (_profileCondition.ValidatePassword(command.user_password, ref message))
                {
                    if (_repository.GetUserByEmail(command.user_email) == null)
                    {
                        var user = new User
                        {
                            Email        = command.user_email,
                            Login        = command.user_login,
                            Password     = _profileCondition.HashPassword(command.user_password),
                            Hash         = _profileCondition.GenerateHash(100),
                            CreatedAt    = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                            Activate     = 0,
                            LastLoginAt  = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                            Token        = _profileCondition.GenerateHash(40),
                            RecoveryCode = 0,
                            PublicToken  = _profileCondition.GenerateHash(20),
                            Profile      = new Profile()
                        };
                        user = _repository.AddUser(user);
                        _mailer.SendEmail(user.Email, "Activate account",
                                          $"Activate account url: <a href=http://{_hostSettings.Ip}:{_hostSettings.PortHttp}"
                                          + $"/v1.0/users/Activate/?hash={user.Hash}>Activation url!</a>");
                        _logger.LogInformation("Create new user, id ->" + user.Id);
                        return(Ok(new MessageResponse(true,
                                                      "User account was successfully registrate. See your email to activate account by url.")));
                    }
                    else
                    {
                        message = "This email is already exists.";
                    }
                }
                else
                {
                    message = "Password not valid. " + message;
                }
            }
            else
            {
                message = $"Email -> {command.user_email} not valid.";
            }

            _logger.LogWarning(message);
            var response = new MessageResponse(false, message);

            return(StatusCode(500, response));
        }
Esempio n. 3
0
        public ActionResult SendMail(SendMailModel model)
        {
            try
            {
                _mailer.SendEmail(model.Subject, model.Body, model.EmailAddress, _config.CompanyName);
                ViewBag.IsPopupAlert = true;
                ViewBag.AlertOptions = new AlertOptions
                {
                    AlertType    = EAlertType.Success,
                    Message      = Dictionary.Success,
                    OtherMessage = "Your email was sent!"
                };
            }
            catch (Exception e)
            {
                ViewBag.IsPopupAlert = true;
                ViewBag.AlertOptions = new AlertOptions
                {
                    AlertType    = EAlertType.Fail,
                    Message      = Dictionary.Error,
                    OtherMessage = e.Message
                };
            }

            return(View("Index"));
        }
Esempio n. 4
0
        private void SendEmailToNineStar(Donation donation)
        {
            var template = Dictionary.DonationReceivedEmail;
            var title    = "We have received a donation!";

            _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new
            {
                Title = title,
                donation.Customer,
                donation.CustomerEmail,
                Amount = donation.DonationAmount,
                donation.Currency,
                LinkToSummary = _urlHelper.AbsoluteAction("Index", "Donations"),
                Company       = _config.CompanyName,
                ImageUrl      = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl)
            }), _config.SupportEmailAddress, _config.CompanyName, _config.SupportEmailAddress, _config.CompanyName);
        }
Esempio n. 5
0
        private void SendEmailToVibrantHealth(UserMembership userMembership, PromoCode promoCode)
        {
            var template = Dictionary.MembershipCreatedEmail;
            var title    = "We have received a new subscription!";

            _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new
            {
                Title            = title,
                Customer         = userMembership.User.FullName,
                CustomerEmail    = userMembership.User.EmailAddress,
                SubscriptionType = userMembership.MembershipOption.SubscriptionTypeNameLocal,
                TotalPrice       = promoCode?.FormattedPrice ?? userMembership.MembershipOption.FormattedPrice,
                LinkToSummary    = _urlHelper.AbsoluteAction("Index", "UserMemberships"),
                Company          = _config.CompanyName,
                ImageUrl         = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl)
            }), _config.SupportEmailAddress, _config.CompanyName, _config.SupportEmailAddress, _config.CompanyName);
        }
Esempio n. 6
0
        private void SendEmailToVibrantHealth(Consultation consultation, Contact contact)
        {
            var template = Dictionary.ConsultationBookedEmail;
            var title    = "We have received a consultation booking!";

            _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new
            {
                Title         = title,
                ContactName   = contact.FullName,
                CustomerEmail = contact.EmailAddress,
                contact.PhoneNumber,
                Duration = consultation.DurationDescription,
                Price    = consultation.FormattedPrice,
                Company  = _config.CompanyName,
                ImageUrl = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl)
            }), _config.SupportEmailAddress, _config.CompanyName, _config.SupportEmailAddress, _config.CompanyName);
        }
Esempio n. 7
0
        public void DeleteMovie(int id)
        {
            var movieToDelete = _context.Movies.Find(id);

            if (movieToDelete != null)
            {
                _context.Movies.Remove(movieToDelete);
                _context.SaveChanges();
                _log.InfoFormat("Movie with id {0} and name {1} was deleted!", movieToDelete.Id, movieToDelete.Name);
                _mailer.SendEmail("*****@*****.**", "*****@*****.**", string.Format("Movie with name {0} was deleted!", movieToDelete.Name));
            }
        }
Esempio n. 8
0
        public async Task <IActionResult> EmailForm(EmailForm form)
        {
            if (!ModelState.IsValid)
            {
                return(View("Oops"));
            }

            form.Id = Guid.NewGuid();
            var response = await mailer.SendEmail(form);

            if (response.StatusCode.ToString() != "Accepted")
            {
                return(View("Oops"));
            }

            return(View("ThankYou", form));
        }
Esempio n. 9
0
        public ActionResult ContactUs(ContactUsViewModel model)
        {
            try
            {
                _mailer.SendEmail(
                    model.Subject,
                    model.Body,
                    _config.SupportEmailAddress,
                    _config.CompanyName,
                    model.EmailAddress,
                    model.Name);

                return(RedirectToAction("ContactUsSuccess"));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.GetFullErrorMessage());
                return(View("FriendlyError"));
            }
        }
        public void Handle(NotifyRequestForSiteReceived message)
        {
            var userEmails = message.UserIds.Select(u => _userService.GetUser(u).EmailAddress).ToList();

            if (userEmails.Count == 0)
            {
                return;
            }

            var siteProvisionEmail = new RequestForSiteReceivedEmail
            {
                To          = userEmails,
                ProjectId   = message.ProjectId.ToString(),
                ProjectName = message.ProjectName,
                Subject     = EmailTemplateSubject.RequestForSiteReceivedSubject
            };

            Log.InfoFormat("[URDMS] Sending Request For Site Received email. {0}.", siteProvisionEmail);
            _mailer.SendEmail(siteProvisionEmail, "RequestForSiteReceived");
        }
Esempio n. 11
0
        public void SendPromoCode(EmailPromoCodeViewModel model)
        {
            var template = Dictionary.PromoCodeEmail;
            var title    = Dictionary.PromoCodeEmailTitle;
            var contact  = _contactService.GetOrCreateContact("", model.Name, model.EmailAddress);

            _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new
            {
                Title = title,
                model.FirstName,
                model.EmailAddress,
                ImageUrl          = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl),
                PrivacyPolicyLink = _urlHelper.AbsoluteAction("PrivacyPolicy", "Home"),
                UnsubscribeLink   = _urlHelper.AbsoluteAction("Unsubscribe", "Account", new { code = contact.Name }),
                PromoLink         = _urlHelper.AbsoluteAction("Register", "Account", new { promoCode = model.PromoCode.Code }),
                PromoDetails      = model.PromoCode.Details,
                DateTime.Now.Year
            }), model.EmailAddress, model.Name, _config.SupportEmailAddress, _config.CompanyName);

            model.PromoCode.SentOn = DateTime.Now;
            _promoCodesRepository.Update(model.PromoCode);
        }
Esempio n. 12
0
 public void CreateDonation(Donation donation)
 {
     try
     {
         _donationRepository.Create(donation);
         _mailer.SendEmail("New Donation", TemplateProcessor.PopulateTemplate(Globalisation.Dictionary.DonationReceivedEmail, new
         {
             Title = "We have received a donation!",
             donation.Customer,
             donation.CustomerEmail,
             Amount = donation.DonationAmount,
             donation.Currency,
             LinkToSummary = _urlHelper.AsboluteAction("Index", "Donations"),
             Company       = _config.CompanyName,
             ImageUrl      = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl)
         }), _config.SupportEmailAddress, _config.CompanyName, _config.SupportEmailAddress, _config.CompanyName);
     }
     catch (Exception ex)
     {
         _logger.Error($"DonationService => CreateDonation => {ex.Message}");
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Handles the ApprovalStateChanged message.
        /// </summary>
        /// <param name="message">ApprovalStateChanged message.</param>
        public void Handle(NotifyApprovalStateChanged message)
        {
            var emailData = _approvalStateChangedRepository.Get(message.DataCollectionId);

            switch (message.ApprovalState)
            {
            case "Submitted":
                var submittedStateEmail = new ApprovalStateChangedEmail
                {
                    To = new List <string> {
                        _qaApprovalGroupEmail
                    },
                    Subject             = EmailTemplateSubject.ApprovalStateChangedSubmittedSubject,
                    ProjectTitle        = emailData.ProjectTitle,
                    DataCollectionTitle = emailData.DataCollectionTitle,
                    DataCollectionOwner = emailData.Manager,
                    ApproverId          = message.Approver,
                    ApproverName        = GetApproverName(message.Approver)
                };

                Log.InfoFormat("[URDMS] Sending Approval State Changed email. {0}.", submittedStateEmail);
                _mailer.SendEmail(submittedStateEmail, "ApprovalStateChangedSubmitted");
                break;

            case "QaApproved":
                var qaApprovedStateEmail = new ApprovalStateChangedEmail
                {
                    To = new List <string> {
                        _secondaryApprovalGroupEmail
                    },
                    Subject             = EmailTemplateSubject.ApprovalStateChangedQaApprovedSubject,
                    ProjectTitle        = emailData.ProjectTitle,
                    DataCollectionTitle = emailData.DataCollectionTitle,
                    DataCollectionOwner = emailData.Manager,
                    ApproverId          = message.Approver,
                    ApproverName        = GetApproverName(message.Approver)
                };
                Log.InfoFormat("[URDMS] Sending Approval State Changed email. {0}.", qaApprovedStateEmail);
                _mailer.SendEmail(qaApprovedStateEmail, "ApprovalStateChangedQaApproved");
                break;

            case "SecondaryApproved":
                var secondaryApprovedStateEmail = new ApprovalStateChangedEmail
                {
                    To = new List <string> {
                        _qaApprovalGroupEmail
                    },
                    Subject             = EmailTemplateSubject.ApprovalStateChangedSecondaryApprovedSubject,
                    ProjectTitle        = emailData.ProjectTitle,
                    DataCollectionTitle = emailData.DataCollectionTitle,
                    DataCollectionOwner = emailData.Manager,
                    ApproverId          = message.Approver,
                    ApproverName        = GetApproverName(message.Approver)
                };

                Log.InfoFormat("[URDMS] Sending Approval State Changed email. {0}.", secondaryApprovedStateEmail);
                _mailer.SendEmail(secondaryApprovedStateEmail, "ApprovalStateChangedSecondaryApproved");
                break;

            case "RecordAmended":
                var recordAmendedStateEmail = new ApprovalStateChangedEmail
                {
                    To = new List <string> {
                        _secondaryApprovalGroupEmail
                    },
                    Subject             = EmailTemplateSubject.ApprovalStateChangedRecordAmendedSubject,
                    ProjectTitle        = emailData.ProjectTitle,
                    DataCollectionTitle = emailData.DataCollectionTitle,
                    DataCollectionOwner = emailData.Manager,
                    ApproverId          = message.Approver,
                    ApproverName        = GetApproverName(message.Approver)
                };

                Log.InfoFormat("[URDMS] Sending Approval State Changed email. {0}.", recordAmendedStateEmail);
                _mailer.SendEmail(recordAmendedStateEmail, "ApprovalStateChangedRecordAmended");
                break;

            case "Published":
                var managerEmailAddress = _userService.GetUser(emailData.ManagerId).EmailAddress;
                var publishedStateEmail = new ApprovalStateChangedEmail
                {
                    To = new List <string> {
                        managerEmailAddress
                    },
                    Subject             = EmailTemplateSubject.ApprovalStateChangedPublishedSubject,
                    ProjectTitle        = emailData.ProjectTitle,
                    DataCollectionTitle = emailData.DataCollectionTitle
                };

                Log.InfoFormat("[URDMS] Sending Approval State Changed email. {0}.", publishedStateEmail);
                _mailer.SendEmail(publishedStateEmail, "ApprovalStateChangedPublished");
                break;
            }
        }