コード例 #1
0
        public void SendAdminBroadcastMail(string subject, string message)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                var list = UserEmailQueryFunc().Execute();

                var unconfirmedMailsQuery = UserEmailQueryFunc();
                unconfirmedMailsQuery.Filter = new UserEmailFilter {
                    MailConfirmed = false, MailUnconfirmed = true
                };

                var failedUserNamesList = unconfirmedMailsQuery.Execute().Select(dto => dto.UserName).ToList();

                foreach (var userMail in list)
                {
                    try
                    {
                        MailerService.SendAdminBroadcastMail(userMail.Email, subject, message);
                    }
                    catch (Exception)
                    {
                        failedUserNamesList.Add(userMail.UserName);
                    }
                }

                if (failedUserNamesList.Count > 0)
                {
                    throw new UIException(string.Format("Nasledujúcim užívateľom sa nepodarilo poslať mail: {0}", string.Join <string>(", ", failedUserNamesList)));
                }
            }
        }
コード例 #2
0
        // CRUD
        public long RegisterUserAccount(UserDto userDto, long userId)
        {
            // gen random string and hash
            var unhashedPassword = CommonHelperAppService.RandomString(8);

            userDto.Password = unhashedPassword;

            var user = Mapper.Map <User>(userDto);

            user.Password = HashPassword(unhashedPassword);

            _unitOfWork.UserRepository.Create(user);
            _unitOfWork.Save();


            // Mail
            MailerService.SendUserRegisteredEmail(userDto);

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeCreate,
                AppConstants.UserTableName,
                userId,
                user.Id);

            return(user.Id);
        }
コード例 #3
0
        public bool PasswordReset(string emailAddress)
        {
            // get user based upon email address
            var user = _unitOfWork.UserRepository.Get(u => u.Email == emailAddress).FirstOrDefault();

            if (user != null)
            {
                // for use below with unhashed password
                var userDto = Mapper.Map <UserDto>(user);

                // generate new password from Random
                userDto.Password = CommonHelperAppService.RandomString(8);

                // Hash it. Hash it, real good!
                user.Password = CommonHelperAppService.HashPassword(userDto.Password);

                _unitOfWork.UserRepository.Update(user);
                _unitOfWork.Save();

                MailerService.SendPasswordResetEmail(userDto);

                return(true);
            }

            return(false);
        }
コード例 #4
0
 public SendRegistrationConfirmationHandler(IOrdersApi ordersApi, IEventsApi eventsApi, MailerService mailerService, MailTemplatesFacade mailTemplatesFacade)
 {
     this.ordersApi           = ordersApi;
     this.eventsApi           = eventsApi;
     this.mailerService       = mailerService;
     this.mailTemplatesFacade = mailTemplatesFacade;
 }
コード例 #5
0
 public TicketController()
 {
     _ticketQueriesService  = new TicketQueriesService();
     _viewUtilityServices   = new ViewUtilityServices();
     _ticketCommandsService = new TicketCommandsService();
     _searchQueriesService  = new SearchQueriesService();
     _mailerService         = new MailerService();
 }
コード例 #6
0
 public AccountsController(AccountService accountService, PaymentService paymentService, NotificationService notificationService, IConfiguration config, MailerService mailerService)
 {
     _accountService      = accountService;
     _paymentService      = paymentService;
     _notificationService = notificationService;
     _config        = config;
     _mailerService = mailerService;
 }
コード例 #7
0
        public ActionResult Index()
        {
            var sendMail = MailerService.SendEmail("*****@*****.**", "subject", "hello world message");

            ViewBag.Title = "Home Page";

            var user  = Request.LogonUserIdentity.Name;
            var user2 = System.Web.HttpContext.Current.User.Identity.Name;

            return(View());
        }
コード例 #8
0
    protected void sendEmail()
    {
        LoginDetails loginDetails = User.Identity as LoginDetails;
        string       userId       = loginDetails.UserId;
        string       subject      = "Stationery Requistion by " + loginDetails.Name;
        List <Stationery_Catalogue> stationeryCatalogueList = (List <Stationery_Catalogue>)Session["Cart"];
        User   headUser = UserDAO.GetUserdOfDeptHead(Convert.ToInt32(userId));
        String body     = setEmailBody();

        MailerService.SendEmail(headUser.Email, headUser.Employee.Name, subject, body);
    }
コード例 #9
0
        public async Task RequestEmailChange(string newEmail)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                using (var manager = AppUserManagerFactory())
                {
                    var user = await manager.FindByIdAsync(CurrentUser.Id.ToString());

                    var token = await manager.GenerateChangeEmailTokenAsync(user, newEmail);

                    await MailerService.SendEmailChangeConfirmationEmailAsync(newEmail, token);
                }
            }
        }
コード例 #10
0
        public async Task RegisterUser(RegisterDTO data)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                using (var manager = AppUserManagerFactory())
                {
                    var user = await manager.FindByEmailAsync(data.Email);

                    if (user == null)
                    {
                        user = new User()
                        {
                            Email          = data.Email,
                            DateCreated    = DateTime.Now,
                            EmailFrequency = EmailFrequency.Daily,
                            UserName       = data.Email,
                            FullName       = data.FullName,
                            CompanyName    = data.CompanyName,
                            Enabled        = true
                        };
                        var createResult = await manager.CreateAsync(user, data.Password);

                        if (!createResult.Succeeded)
                        {
                            throw new UIException($"Registrace se nezdařila. Ujistěte se, že heslo obsahuje alespoň 12 znaků.");
                        }
                    }
                    else if (!user.Enabled)
                    {
                        throw new UIException($"Účet s danou e-mailovou adresou byl již zrušen. Pokud jej chcete obnovit, kontaktujte administrátora.");
                    }
                    else if (user.EmailConfirmed)
                    {
                        throw new UIException($"Účet s danou e-mailovou adresou již existuje.");
                    }
                    else
                    {
                        user.FullName    = data.FullName;
                        user.CompanyName = data.CompanyName;
                    }

                    // send activation email
                    await uow.CommitAsync();

                    var token = await manager.GenerateEmailConfirmationTokenAsync(user);

                    await MailerService.SendEmailAddressConfirmationEmailAsync(data, token);
                }
            }
        }
コード例 #11
0
        public async Task SendResetPasswordEmail(ForgottenPasswordDTO data)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                using (var manager = AppUserManagerFactory())
                {
                    var user = await manager.FindByEmailAsync(data.Email);

                    if (user == null)
                    {
                        throw new UIException("Zadaná e-mailová adresa nebyla nalezena.");
                    }

                    var token = await manager.GeneratePasswordResetTokenAsync(user);

                    await MailerService.SendPasswordResetEmailAsync(data, token);
                }
            }
        }
コード例 #12
0
        public void Should_Send_New_User_Email_with_Account_Password()
        {
            // Arrange
            var userDto = new UserDto
            {
                Email              = "*****@*****.**",
                Firstname          = "Test",
                Lastname           = "User",
                IsAccountLocked    = false,
                IsActive           = true,
                SystemAccessRoleId = 1,
                Password           = CommonHelperAppService.RandomString(8)
            };

            // Act
            MailerService.SendUserRegisteredEmail(userDto);

            // Assert
            //Assert.AreEqual(expected, result);
        }
コード例 #13
0
        public ActionResult ForgotPassword(string email)
        {
            var userManager = HttpContext.GetOwinContext().GetUserManager <UserManager <IdentityUser> >();
            var user        = userManager.FindByEmail(email);

            if (user != null)
            {
                string resetToken = userManager.GeneratePasswordResetToken(user.Id);
                string resetUrl   = Request.Url.GetLeftPart(UriPartial.Authority) + "/Account/ResetPassword?email=" + email + "&token=" + resetToken;
                string link       = string.Format("<a href=\"{0}\">Reset your password</a>", resetUrl);
                //userManager.SendEmail(user.Id, "your password reset token", message);
                EmailMessageMaker forgotPasswordEmail = new EmailMessageMaker();
                forgotPasswordEmail.Line.Add("<h2>Thank you for contacting us!</h2>");
                forgotPasswordEmail.Line.Add("<p>To reset your password, please click on the link below.</p>");
                forgotPasswordEmail.Line.Add(link);
                forgotPasswordEmail.Line.Add("<p>Have a great day!</p>");
                MailerService passwordReset = new MailerService(user.Email, "Instructions to reset your VGM password", forgotPasswordEmail);
                passwordReset.SendMail();
            }

            return(RedirectToAction("ForgotPasswordSent"));
        }
コード例 #14
0
        private void SendTempEmailToMaddie(ShiftDto shiftDto)
        {
            // TEMP BITS FOR BALDOCK ###################################################################################
            var mosName = string.Empty;

            // get user details from employeeId
            if (shiftDto.EmployeeId != null)
            {
                var employee = _unitOfWork.EmployeeRepository.GetById(shiftDto.EmployeeId);
                employee.User = _unitOfWork.UserRepository.GetById(employee.UserId);
                mosName       = employee.User.Firstname + " " + employee.User.Lastname;
            }

            var tempShiftTemplate = _unitOfWork.ShiftTemplateRepository.GetById(shiftDto.ShiftTemplateId);
            var tempSite          = _unitOfWork.SiteRepository.GetById(tempShiftTemplate.SiteId);
            var siteName          = tempSite.Name;

            if (tempShiftTemplate.SubSiteId != null)
            {
                var tempSubSite = _unitOfWork.SubSiteRepository.GetById(tempShiftTemplate.SubSiteId);
                siteName = tempSubSite.Name;
            }

            var tempEmailDto = new TempMaddieEmailDto
            {
                ShiftEndDateTime    = shiftDto.EndDate.ToString(),
                ShiftStartDateTime  = shiftDto.StartDate.ToString(),
                ShiftLocation       = siteName,
                ShiftNewStaffMember = mosName,
                ShiftOldStaffMember = shiftDto.TempCurrentStaffMember,
                ResourceTypeName    = shiftDto.TempResourceTypeName
            };

            // TEMP EMAIL - send details about shift and changes from here
            MailerService.SendTempMaddieEmail(tempEmailDto);
            // ########################################################################################################
        }
コード例 #15
0
 public EmailLogger(string recipientAddress, MailerService mailerService, IDateTimeNowProvider dateTimeNowProvider, IEnumerable <IAdditionalDataProvider> additionalDataProviders = null) : base(dateTimeNowProvider, additionalDataProviders)
 {
     this.recipientAddress = recipientAddress;
     this.mailerService    = mailerService;
     MinimumSeverity       = Severity.Error;
 }
コード例 #16
0
 public void SendTimeAdjustmentForm(TimeAdjustmentFormDto timeAdjustmentFormDto)
 {
     MailerService.SendTimeAdjustmentEmail(timeAdjustmentFormDto);
 }
コード例 #17
0
 public SendInvoiceRequestHandler(IOrdersApi ordersApi, MailTemplatesFacade mailTemplatesFacade, MailerService mailerService)
 {
     this.ordersApi           = ordersApi;
     this.mailTemplatesFacade = mailTemplatesFacade;
     this.mailerService       = mailerService;
 }