// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var logger = new ConsoleLogger(); var requestMaker = new WebRestRequestMaker(); var settings = new EnvironmentVariableSettings(); var meetSheetFactory = new MeetsGoogleSheetFactory(); var emailAddressSheetFactory = new EmailAddressGoogleSheetFactory(); var dateTimeService = new DateTimeService(); var meetsService = new MeetsService( settings, requestMaker, meetSheetFactory, dateTimeService, logger); var emailAddressService = new EmailAddressService( settings, requestMaker, emailAddressSheetFactory, logger); var emailSenderService = new EmailSenderService(settings); services.AddSingleton <ILogger>(logger); services.AddSingleton <ISettings>(settings); services.AddSingleton <IMeetsService>(meetsService); services.AddSingleton <IEmailAddressService>(emailAddressService); services.AddSingleton <IEmailSenderService>(emailSenderService); }
public AdminController( IModuleChangeRepository moduleChangeRepository, CompanyService companyService, IUserRepository userRepository, LicenseService licenseService, ILicenseRepository licenseRepository, ICompanyRepository companyRepository, IInvoiceRepository invoiceRepository, IModuleRepository moduleRepository, InvoiceService invoiceService, IDefaultModuleRepository defaultModuleRepository, IDefaultLicenseRepository defaultLicenseRepository, EmailSenderService emailService) { this.emailService = emailService; this.moduleChangeRepository = moduleChangeRepository; this.licenseService = licenseService; this.userRepository = userRepository; this.companyService = companyService; this.licenseRepository = licenseRepository; this.companyRepository = companyRepository; this.invoiceRepository = invoiceRepository; this.moduleRepository = moduleRepository; this.invoiceService = invoiceService; this.defaultModuleRepository = defaultModuleRepository; this.defaultLicenseRepository = defaultLicenseRepository; }
public async Task <IActionResult> Register(User user) { if (user == null) { return(BadRequest()); } user.Role = UserRole.Executor; user.AccountStatus = AccountStatus.Inactive; Response <SecureUser> response = await userService.Create(user); if (!response.Success) { return(BadRequest(response.Message)); } try { EmailSenderService emailSender = new EmailSenderService(config); emailSender.SendEmail(user.Email, "Registration successful", "Wait for account activation"); } catch { logger.LogInformation("Invalid email settings"); } return(Ok("Wait for account activation.")); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, EmailSenderService emailSender) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } // app.UseHttpsRedirection(); app.UseRouting(); app.UseExceptionHandler(errorApp => { errorApp.Run(async context => { var props = errorApp.Properties.ToList(); context.Response.StatusCode = 320; await context.Response.WriteAsync(""); }); }); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
private void SendEmail(Usuario usuario, List <Diccionario> data, List <Diccionario> dataSAC) { var correoDiners = System.Configuration.ConfigurationManager.AppSettings["CorreoDinersSac"]; var emailsTo = new List <string>(); if (!string.IsNullOrEmpty(usuario.EmailPrincipal)) { string correoUsuario = usuario.EmailSeleccionado == "1" ? usuario.EmailPrincipal : usuario.EmailAlternativo; emailsTo.Add(correoUsuario); } var emailsToDiners = new List <string>(); emailsToDiners.Add(correoDiners); var emailsCc = new List <string>(); emailsCc.Add(usuario.EmailAlternativo); try { var content = EmailHelper.CrearHtmlOperacionEmail(usuario.Socio.NombreCompleto, data); EmailSenderService.SendEmail("Canal Web – SOLICITUD INGRESO DE RECLAMO", content, "*****@*****.**", emailsTo, new List <string>(), emailsCc, null); var contentSAC = EmailHelper.CrearHtmlOperacionEmail(usuario.Socio.NombreCompleto, dataSAC); EmailSenderService.SendEmail("Canal Web – SOLICITUD INGRESO DE RECLAMO", contentSAC, "*****@*****.**", emailsToDiners, new List <string>(), new List <string>(), null); } catch (System.Exception) { throw; } }
public JsonResult DisableTutor(int TutorId) { try { Tutor tutor = db.Tutors.SingleOrDefault(s => s.Id == TutorId); if (!tutor.IsEnable) { tutor.IsEnable = true; EmailSenderService.SendHtmlFormattedEmail(tutor.Email, "Mở tài khoản", EmailSenderService.PopulateBody(tutor.FullName, "~/EmailTemplates/EnableAccountNotification.html")); } else { tutor.IsEnable = false; EmailSenderService.SendHtmlFormattedEmail(tutor.Email, "Khóa tài khoản", EmailSenderService.PopulateBody(tutor.FullName, "~/EmailTemplates/DisableAccountNotification.html")); } db.Entry(tutor).State = EntityState.Modified; db.SaveChanges(); } catch (Exception ex) { return(Json(new { Status = "Error" })); } return(Json(new { Status = "OK" })); }
public PrimaryRecoveryForgotPasswordHandler( UserManager <CustomIdentityUser> userManager, EmailSenderService emailSenderService) { _userManager = userManager; _emailSenderService = emailSenderService; }
private async Task InviteAdminAsync() { try { await ButtonSpinner.SpinAsync(async() => { var callBakcUrl = await ApplicationUserService.InviteAdministratorAsync(Invitation.Email, NavigationManager.BaseUri); await EmailSenderService.SendUserInvitationAsync(Invitation.Email, callBakcUrl); await ToastService.ShowToastAsync("Administrator invited.", ToastType.Success); await SynchronizationService.UpdateAdministrators(ExceptPageId); await ModalDialogService.CloseAsync(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(Invitation.Email), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
public EmailConfirmationHandler( UserManager <CustomIdentityUser> userManager, EmailSenderService emailSenderService) { _userManager = userManager; _emailSender = emailSenderService; }
public HttpStatusCodeResult ReceiveClass(int ClassId) { try { string tutorUsername = User.Identity.GetUserName(); string UserId = User.Identity.GetUserId(); RegistrationClass RegistrationClass = db.RegistrationClasses.Include(s => s.Customer).SingleOrDefault(s => s.Id == ClassId); Customer customer = RegistrationClass.Customer; string customerUsername = UserManager.FindById(customer.UserId).UserName; Tutor tutor = db.Tutors.SingleOrDefault(s => s.UserId == UserId); RegistrationClass.Tutor = tutor; RegistrationClass.Status = Enums.ClassStatus.WaitingForCustomerApproval; db.Entry(RegistrationClass).State = EntityState.Modified; db.SaveChanges(); //send to tutor EmailSenderService.SendHtmlFormattedEmail(tutor.Email, "Yêu cầu nhận lớp mã số : " + RegistrationClass.Id, EmailSenderService.PopulateBody(customer.FullName, tutor.FullName, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToTutor.html")); //send to customer EmailSenderService.SendHtmlFormattedEmail(customer.Email, "Yêu cầu nhận lớp", EmailSenderService.PopulateBodyTutorEnrollClassNotificationToCustomer(customer.FullName, tutor, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToCustomer.html")); //send to admin EmailSenderService.SendHtmlFormattedEmail(AdminEmail, "Gia sư đăng kí nhận lớp", EmailSenderService.PopulateBodyTutorEnrollClassNotificationToAdmin(customer, customerUsername, tutor, tutorUsername, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToAdmin.html")); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public ConfirmOrderViewModel() { Random rand = new Random(); code = rand.Next(99999); EmailSenderService.SendCodeRefactor(Settings.Default.UserMail, code, "Код подтверждения", "Никому не сообщайте данный код! \nКод подтверждения: ").GetAwaiter(); }
public AccountController( SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager, EmailSenderService emailSenderService) { _signInManager = signInManager; _userManager = userManager; _emailSenderService = emailSenderService; }
public WeatherForecastController( EmailSenderService service, IMediator mediator, ILogger <WeatherForecastController> logger) { _service = service; _logger = logger; HangfireStaticRef.Mediator = mediator; }
public static void Movimientos_ProcesarEnviarCorreo(string correoDestino, string asunto, Dictionary <MemoryStream, string> attachments) { var mailsTo = new List <string> { correoDestino }; var contenidoCorreo = ""; EmailSenderService.SendEmail(asunto, contenidoCorreo, "*****@*****.**", mailsTo, null, null, attachments); }
public CancelOrderViewModel() { orderForCancelation = App.db.Orders.Where(x => x.OrderId == orderId).FirstOrDefault(); userCard = App.db.Cards.Where(x => x.UserId == Settings.Default.UserId).FirstOrDefault(); Random random = new Random(); code = random.Next(99999); EmailSenderService.SendCodeRefactor(Settings.Default.UserMail, code, "Код отмены", "Никому не сообщайте данный код! \nКод подтверждения: ").GetAwaiter(); }
public ActionResult ClassRegister(Models.BindingModels.ClassRegistrationBindingModel classRegistrationInfo) { if (classRegistrationInfo != null) { string UserId = User.Identity.GetUserId(); string CustomerUsername = User.Identity.GetUserName(); Models.RegistrationClass classInfo = new Models.RegistrationClass(); classInfo.City = classRegistrationInfo.City; classInfo.DayPerWeek = classRegistrationInfo.SessionPerWeek; classInfo.District = classRegistrationInfo.District; if (classRegistrationInfo.Grade != null) { classInfo.Grade = db.Grades.SingleOrDefault(s => s.Id == classRegistrationInfo.Grade); } classInfo.Requirement = classRegistrationInfo.Requirement; classInfo.SalaryPerMonth = classRegistrationInfo.SalaryPerMonth; classInfo.Street = classRegistrationInfo.Street; classInfo.Status = Enums.ClassStatus.WaitingForAdminApproval; Customer customer = db.Customers.SingleOrDefault(s => s.UserId == UserId); classInfo.Customer = customer; if (classRegistrationInfo.Subjects != null && classRegistrationInfo.Subjects.Count > 0) { classInfo.Subjects = new List <Subject>(); foreach (int id in classRegistrationInfo.Subjects) { classInfo.Subjects.Add(db.Subjects.SingleOrDefault(s => s.Id == id)); } } classInfo.TutoringTime = classRegistrationInfo.TeachingTime; classInfo.Ward = classRegistrationInfo.Ward; classInfo.ReceivedDate = null; db.RegistrationClasses.Add(classInfo); db.SaveChanges(); try { //send to customer EmailSenderService.SendHtmlFormattedEmail(customer.Email, "Đăng kí tìm gia sư", EmailSenderService.PopulateBodyRegistrationClassNotificationToCustomer(customer.FullName, classInfo.Id.ToString(), "~/EmailTemplates/ClassRegistrationNotification.html")); //send to admin EmailSenderService.SendHtmlFormattedEmail(AdminEmail, "Có phụ huynh đăng kí tìm gia sư", EmailSenderService.PopulateBodyRegistrationClassNotificationToAdmin(customer.FullName, classInfo.Id.ToString(), CustomerUsername, "~/EmailTemplates/ClassRegistrationNotificationToAdmin.html")); } catch (Exception ex) { return(RedirectToAction("PostedClass", "ManageRegistrationClasses")); } return(RedirectToAction("PostedClass", "ManageRegistrationClasses")); } return(RedirectToAction("ClassRegistrationForm", "Class")); }
private static void TarjetaAdicional_EnviaroCorreoDiners(TarjetaAdicionalViewModel tarjetaAdicional, Usuario usuario, string numeroSolicitud, string fechaRegistro) { var correoDinersSac = ConfigurationManager.AppSettings["CorreoDinersSac"]; var mailsTo = new List <string> { correoDinersSac }; var contenidoCorreo = CrearHtmlOperacionEmail(usuario.Socio.NombreCompleto, tarjetaAdicional.DatosCorreo); EmailSenderService.SendEmail("Canal Web – SOLICITUD TARJETA ADICIONAL", contenidoCorreo, "*****@*****.**", mailsTo, null, null, null); }
private static void BloqueoTarjeta_EnviaroCorreoDiners(List <Diccionario> datosCorreo, string nombreCompleto, string numeroSolicitud, string fechaRegistro) { var correoDinersSac = ConfigurationManager.AppSettings["CorreoDinersSac"]; var mailsTo = new List <string> { correoDinersSac }; var contenidoCorreo = CrearHtmlOperacionEmail(nombreCompleto, datosCorreo); EmailSenderService.SendEmail("Canal Web – BLOQUEO TARJETA", contenidoCorreo, "*****@*****.**", mailsTo, null, null, null); }
public ProfileController(IApplicationUserService userService, IMapper mapper, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IOptions <EmailSettings> emailSettings, EmailSenderService emailSender) { _userService = userService; _mapper = mapper; _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; }
private static void PrestamoPersonal_EnviaroCorreoDiners(PrestamoPersonalViewModel prestamoPersonal, Usuario usuario, string numeroSolicitud, string fechaRegistro) { var correoDinersSac = ConfigurationManager.AppSettings["CorreoDinersSac"]; var mailsTo = new List <string> { correoDinersSac }; var contenidoCorreo = CrearHtmlOperacionEmail(usuario.Socio.NombreCompleto, prestamoPersonal.DatosCorreo); EmailSenderService.SendEmail("Canal Web – OFERTA PRÉSTAMO PERSONAL", contenidoCorreo, "*****@*****.**", mailsTo, null, null, null); }
private static void DineroEfectivo_EnviaroCorreoDiners(DineroEfectivoViewModel dineroEfectivo, Usuario usuario, string numeroSolicitud, string fechaRegistro) { var correoDinersSac = ConfigurationManager.AppSettings["CorreoDinersSac"]; var mailsTo = new List <string> { correoDinersSac }; var contenidoCorreo = CrearHtmlOperacionEmail(usuario.Socio.NombreCompleto, dineroEfectivo.DatosCorreo); EmailSenderService.SendEmail("Canal Web – OFERTA DINERO EN EFECTIVO", contenidoCorreo, "*****@*****.**", mailsTo, null, null, null); }
public async Task <ActionResult> RegisterCustomer(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Username, Email = model.Email, PhoneNumber = model.PhoneNumber }; var result = UserManager.Create(user, model.Password); if (result.Succeeded) { context.Customers.Add(new Customer() { UserId = user.Id, FullName = model.FullName, PhoneNumber = model.PhoneNumber, Email = model.Email, City = model.City, District = model.District, Street = model.Street, Ward = model.Ward, IsActivate = false, IsEnable = true }); await context.SaveChangesAsync(); UserManager.AddToRole(user.Id, "Customer"); try { //send to customer EmailSenderService.SendHtmlFormattedEmail(model.Email, "Đăng kí tài khoản", EmailSenderService.PopulateBody(model.FullName, model.Username, "~/EmailTemplates/AccountRegisterSuccess.html")); //send to admin EmailSenderService.SendHtmlFormattedEmail(AdminEmail, "Phụ huynh đăng kí tài khoản", EmailSenderService.PopulateBody(model.FullName, model.Username, "~/EmailTemplates/AccountRegisterAdminNotification.html")); } catch (Exception ex) { ModelState.AddModelError("", "Tài khoản của bạn đã được tạo thành công ! Vui lòng kiểm tra Email "); return(RedirectToAction("Login", "Account")); } // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); ModelState.AddModelError("", "Tài khoản của bạn đã được tạo thành công ! Vui lòng kiểm tra Email "); return(RedirectToAction("Login", "Account")); } else { return(RedirectToAction("Register", "Account")); } } // If we got this far, something failed, redisplay form return(RedirectToAction("Register", "Account")); }
public HeaderViewComponent(EmailSenderService emailSenderService, GalleryRepository galleryRepo, AppointmentRepository appoitmentRepo, NoticeRepository noticeRepo, SetupRepository setupRepo, PageCategoryRepository pageCategoryRepo, EventRepository eventRepo, ServicesRepository serviceRepository) { _galleryRepo = galleryRepo; _noticeRepo = noticeRepo; _setupRepo = setupRepo; _pageCategoryRepo = pageCategoryRepo; _eventRepo = eventRepo; _appointmentRepo = appoitmentRepo; _serviceRepository = serviceRepository; _emailSenderService = emailSenderService; }
public AccountController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, EmailSenderService emailSender, ILogger <AccountController> logger) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _logger = logger; }
private async Task SendEmailAsync() { try { await EmailSenderService.SendHardwareVaultActivationCodeAsync(HardwareVault.Employee, Code); } catch (Exception ex) { Logger.LogError(ex.Message); } }
public RegistrationController(UserManager <ApplicationUserEntity> userManager, IMapper mapper, ApplicationDbContext context, IConfiguration applicationConfiguration) { this.context = context; this.userManager = userManager; this.mapper = mapper; this.emailValidatorService = new EmailValidatorService(); emailService = new EmailSenderService(applicationConfiguration); }
private async Task SendEmailAsync() { if (string.IsNullOrWhiteSpace(Email)) { return; } await EmailSenderService.SendHardwareVaultActivationCodeAsync(new Employee() { FirstName = Employee.FirstName, LastName = Employee.LastName, Email = Email }, Code); }
public async Task <OperationResult <@event> > PostEventAsync(CreateEvent eve) { var res = await Post(eve); if (!res.Success) { return(res); } EmailSenderService.SendQrCodeToAdmins(res.Result); return(res); }
private async Task ResendInviteAsync() { try { var callBakcUrl = await ApplicationUserService.GetCallBackUrl(DataTableService.SelectedEntity.Email, NavigationManager.BaseUri); await EmailSenderService.SendUserInvitationAsync(DataTableService.SelectedEntity.Email, callBakcUrl); await ToastService.ShowToastAsync("Administrator invited.", ToastType.Success); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private static void EnviaroCorreoSocio(List <Diccionario> datos, string nombreCompleto, string correoUsuario, string asunto, string numeroSolicitud, string fechaRegistro) { var mailsTo = new List <string> { correoUsuario }; datos.Insert(0, new Diccionario { Key = "Fecha y hora", Value = fechaRegistro }); datos.Insert(1, new Diccionario { Key = "Nº Solicitud", Value = numeroSolicitud }); var contenidoCorreo = CrearHtmlOperacionEmail(nombreCompleto, datos); EmailSenderService.SendEmail(asunto, contenidoCorreo, "*****@*****.**", mailsTo, null, null, null); }