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))); } } }
// 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); }
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); }
public SendRegistrationConfirmationHandler(IOrdersApi ordersApi, IEventsApi eventsApi, MailerService mailerService, MailTemplatesFacade mailTemplatesFacade) { this.ordersApi = ordersApi; this.eventsApi = eventsApi; this.mailerService = mailerService; this.mailTemplatesFacade = mailTemplatesFacade; }
public TicketController() { _ticketQueriesService = new TicketQueriesService(); _viewUtilityServices = new ViewUtilityServices(); _ticketCommandsService = new TicketCommandsService(); _searchQueriesService = new SearchQueriesService(); _mailerService = new MailerService(); }
public AccountsController(AccountService accountService, PaymentService paymentService, NotificationService notificationService, IConfiguration config, MailerService mailerService) { _accountService = accountService; _paymentService = paymentService; _notificationService = notificationService; _config = config; _mailerService = mailerService; }
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()); }
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); }
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); } } }
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); } } }
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); } } }
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); }
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")); }
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); // ######################################################################################################## }
public EmailLogger(string recipientAddress, MailerService mailerService, IDateTimeNowProvider dateTimeNowProvider, IEnumerable <IAdditionalDataProvider> additionalDataProviders = null) : base(dateTimeNowProvider, additionalDataProviders) { this.recipientAddress = recipientAddress; this.mailerService = mailerService; MinimumSeverity = Severity.Error; }
public void SendTimeAdjustmentForm(TimeAdjustmentFormDto timeAdjustmentFormDto) { MailerService.SendTimeAdjustmentEmail(timeAdjustmentFormDto); }
public SendInvoiceRequestHandler(IOrdersApi ordersApi, MailTemplatesFacade mailTemplatesFacade, MailerService mailerService) { this.ordersApi = ordersApi; this.mailTemplatesFacade = mailTemplatesFacade; this.mailerService = mailerService; }