public Tuple <bool, dynamic, string> SendIdCardEmail(int employerId, MemberCardWebRequest cardWebRequest) { var isSuccess = false; dynamic data = new ExpandoObject(); var errorMessage = string.Empty; try { var fileId = Guid.NewGuid(); // Retrieve the web request stream from the Media website and convert it into an SVG file data.SvgSuccess = GetCardSvg(employerId, cardWebRequest, fileId); // Convert the SVG file into a PDF file var cardPdfFile = RenderCardPdf(employerId, fileId); var subject = string.IsNullOrEmpty(cardWebRequest.Subject) ? "Member ID Card" : cardWebRequest.Subject; var message = string.IsNullOrEmpty(cardWebRequest.Message) ? "Please see the attached PDF to view or print my ID card." : cardWebRequest.Message; var useInternalServer = EmailConfiguration.Settings.UseInternalServer; // Send PDF file as an email attachment to designated recipient isSuccess = EmailMessenger.Send(to: cardWebRequest.ToEmail, cc: cardWebRequest.CcEmail, subject: subject, message: message, isHtml: false, attachmentPath: cardPdfFile, isInternalServer: useInternalServer); } catch (Exception exc) { errorMessage = exc.Message; } return(new Tuple <bool, dynamic, string>(isSuccess, data, errorMessage)); }
public ActionResult Contact(ContactUs newmsg) { ViewBag.Canonical = new HtmlString("<link rel=\"canonical\" href=\"" + Request.Url.AbsoluteUri + " \">"); if (!ModelState.IsValid) { return(View(Mapper.Map <ContactUsForm>(newmsg))); } // add to db if (BaseManager.AddGenericMessage(Mapper.Map <GenericMessage>(newmsg))) { string sendTo; if (newmsg.Title.Equals("Feedback/Suggestions")) { sendTo = "*****@*****.**"; } else if (newmsg.Title.Equals("Marketing") || newmsg.Title.Equals("How can i advertize on your site")) { sendTo = "*****@*****.**"; } else { sendTo = "*****@*****.**"; } EmailMessenger.SendContactUsMessage(newmsg, sendTo); ViewBag.Message = "Your message sent successfully. We will respond, if necessary, within 24hrs. Thank you."; ModelState.Clear(); return(View()); } else { ViewBag.Message = "Message failed to send. Try again or use a different method."; return(View()); } }
public static IEmailMessenger InitMessengerForUserUpdatePassword() { var messenger = new EmailMessenger(); messenger.Subject = "Epiworx Notification - Your password was changed"; messenger.Message = "Your password for you account has been successfully changed!"; messenger.Recipients.Add("*****@*****.**"); return(messenger); }
public static IEmailMessenger InitMessengerForUserEdit() { var messenger = new EmailMessenger(); messenger.Subject = "Epiworx Notification - Your user profile was updated"; messenger.Message = "Your account has been successfully updated!"; messenger.Recipients.Add("*****@*****.**"); return(messenger); }
public static IEmailMessenger InitMessengerForUserCreate() { var messenger = new EmailMessenger(); messenger.Subject = "Epiworx Notification - Welcome to Epiworx!"; messenger.Message = "Welcome to Epiworx! Your account has been successfully created!"; messenger.Recipients.Add("*****@*****.**"); return(messenger); }
public static IEmailMessenger InitMessengerForUserResetPassword(string password) { var messenger = new EmailMessenger(); messenger.Subject = "Epiworx Notification - Your password was reset"; messenger.Message = string.Format( "Your password for you account has been successfully reset to {0}!", password); messenger.Recipients.Add("*****@*****.**"); return(messenger); }
public static IEmailMessenger InitializeMessageForUserPasswordChange(string email) { var messenger = new EmailMessenger(); messenger.Subject = "Epiworx Notification - Your password was changed"; messenger.Message = "Your password for you account has been successfully changed!"; messenger.Recipients.Add(email); return(messenger); }
public static IEmailMessenger InitializeMessageForUserEdit(string email) { var messenger = new EmailMessenger(); messenger.Subject = "Epiworx Notification - Your user profile was updated"; messenger.Message = "Your account has been successfully updated!"; messenger.Recipients.Add(email); return(messenger); }
public static IEmailMessenger InitializeMessageForUserPasswordReset(string email) { var messenger = new EmailMessenger(); messenger.Subject = "Epiworx Notification - Your password was reset"; messenger.Message = string.Format( "Your password for you account has been successfully reset to {0}!", MessageParameter.Password); messenger.Recipients.Add(email); return(messenger); }
public static IEmailMessenger InitializeMessageForUserCreate(string email) { var messenger = new EmailMessenger(); messenger.Subject = "Epiworx Notification - Welcome to Epiworx!"; messenger.Message = string.Format("Welcome <b>{0}</b> to Epiworx! Your account has been successfully created!", MessageParameter.UserName); messenger.Recipients.Add(email); return(messenger); }
public async Task <ActionResult> Confirm(Cart cart, CartViewModel model) { if (ModelState.IsValid) { StringBuilder resultDescription = new StringBuilder(); Order order = new Order(); order.Description = InformationConverter.DescriptionToString(cart.Lines); order.TotalCost = cart.CalcTotalPrice(); order.CustomerInfrom = InformationConverter.UserProfileToString(model.CustomerInformation); order.DateTime = DateTime.Now; if (HttpContext.User.Identity.IsAuthenticated) { order.UserId = HttpContext.User.Identity.GetUserId(); } repository.SaveOrder(order); cart.Clear(); EmailMessenger emailMessenger = new EmailMessenger(model.CustomerInformation.Email); await emailMessenger.SendMessageAsync("Оформление заказа TechUniverse", string.Format("Добрый день, {2}!<br/><br>" + "Ваша заказ #{0} - {1} грн принят!<br/><br>" + "Ожидайте звонка оператора для подтверждения необходимой информации", order.Id, order.TotalCost, model.CustomerInformation.Name)); return(View("ConfirmSuccess")); } else { model.Cart = cart; return(View(model)); } }
static void Main() { var userRepository = new InMemoryUserRepository(); var hotelRepository = new InMemoryHotelRepository(); var smsMessenger = new SmsMessenger(); var emailMessenger = new EmailMessenger(); var users = new User[] { new User("Juanma", smsMessenger, new int[] { 1, 2, 3, 4 }, hotelRepository), new User("Alberto", smsMessenger, new int[] { 1, 3, 5, 7 }, hotelRepository), new User("Emma", emailMessenger, new int[] { 2, 4, 6, 8 }, hotelRepository), new User("Maria", emailMessenger, new int[] { 1, 3, 4, 7, 8 }, hotelRepository) }; foreach (var user in users) { userRepository.Insert(user); } var s = new PromotionSender(userRepository, hotelRepository); s.SendPromotionToEveryone(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //---------------------------------------------------- IConfigService configService = new XMLConfigService("Config.xml"); IMessenger messenger_sms = new SmsMessenger(); IMessenger messenger_email = new EmailMessenger(); IPassHasher passHasher = new SHA256Hasher(); IKeyGenerator smallKeyGenerator = new SmallKeyGenerator(); IKeyGenerator bigKeyGenerator = new BigKeyGenerator(); IRegValidator regValidator = new RegValidator(); IUOWFactory UOWFactory = new EFUOWFactory(configService.ConnectionString); IGetUserDTO getUserDTO = new GetUserDTO(); //---------------------------------------------------- IClaimService claimService = new ClaimService(UOWFactory); //---------------------------------------------------- services.AddSingleton <IConfigService, IConfigService>( serviceProvider => { return(configService); } ); //---------------------------------------------------- services.AddSingleton <IGetUserDTO, IGetUserDTO>( serviceProvider => { return(getUserDTO); } ); //---------------------------------------------------- services.AddSingleton <IUOWFactory, IUOWFactory>( serviceProvider => { return(UOWFactory); } ); services.AddSingleton <IClaimService, ClaimService>(); //----------------------------------------------------- services.AddSingleton <IUserService, UserAuthService>( serviceProvider => { return(new UserAuthService( UOWFactory, new AuthKeyService(smallKeyGenerator, messenger_sms), new AuthKeyService(smallKeyGenerator, messenger_email), passHasher, regValidator, claimService, bigKeyGenerator, getUserDTO )); } ); services.AddSingleton <IProfileService, ProfileService>( serviceProvider => { IConfirmService emailCS = new ConfirmService( new ConfirmKeyService(bigKeyGenerator, messenger_email) ); IConfirmService phoneCS = new ConfirmService( new ConfirmKeyService(smallKeyGenerator, messenger_sms) ); return(new ProfileService( UOWFactory, regValidator, emailCS, phoneCS, passHasher, claimService, getUserDTO )); } ); services.AddSingleton <IRestorePasswordService, RestorePasswordService>( serviceProvider => { var emaiCKS = new ConfirmKeyService(bigKeyGenerator, messenger_email); var phoneCKS = new ConfirmKeyService(smallKeyGenerator, messenger_sms); return(new RestorePasswordService(UOWFactory, emaiCKS, phoneCKS, new RegValidator(), passHasher)); } ); //---------Forum Services-------------------------------- IGroupRules groupRules = new GroupRules(); ISectionRules sectionRules = new SectionRules(groupRules); IThemeRules themeRules = new ThemeRules(sectionRules); IMessageRules messageRules = new MessageRules(themeRules, sectionRules); IDTOHelper dtoHelper = new DTOHelper(); IForumDTOHelper forumDTOHelper = new ForumDTOHelper(messageRules, themeRules, sectionRules, groupRules, dtoHelper); services.AddSingleton <IGroupService, GroupService>( serviceProvider => { return(new GroupService(groupRules, getUserDTO, UOWFactory, forumDTOHelper)); } ); services.AddSingleton <ISectionService, SectionService>( serviceProvider => { return(new SectionService(sectionRules, getUserDTO, UOWFactory, forumDTOHelper)); } ); services.AddSingleton <IThemeService, ThemeService>( serviceProvider => { return(new ThemeService(themeRules, getUserDTO, UOWFactory, forumDTOHelper)); } ); services.AddSingleton <IMessageService, MessageService>( serviceProvider => { return(new MessageService(messageRules, getUserDTO, UOWFactory, forumDTOHelper)); } ); services.AddSingleton <IForumService, ForumService>( serviceProvider => { return(new ForumService(getUserDTO, UOWFactory, forumDTOHelper, groupRules)); } ); //--------------------Page Services-------------------- IPageRules pageRules = new PageRules(); INoteRules noteRules = new NoteRules(); services.AddSingleton <IPageService, PageService>( serviceProvider => { return(new PageService(pageRules, UOWFactory, getUserDTO, dtoHelper)); } ); services.AddSingleton <IBlogService, BlogService>( serviceProvider => { return(new BlogService(noteRules, UOWFactory, getUserDTO, dtoHelper)); } ); //------------------------------------------------------- services.AddSingleton <IImageService, ImageService>( serviceProvider => { return(new ImageService(UOWFactory, getUserDTO)); } ); //------------------------------------------- services.AddSingleton <IAdminService, AdminService>( serviceProvider => { return(new AdminService(getUserDTO, UOWFactory)); } ); services.Configure <FormOptions>(x => { x.ValueCountLimit = int.MaxValue; x.MemoryBufferThreshold = int.MaxValue; x.ValueLengthLimit = int.MaxValue; x.MultipartBodyLengthLimit = int.MaxValue; // In case of multipart }); //------------------------------------------------------ services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = new Microsoft.AspNetCore.Http.PathString("/Account/Login"); options.LogoutPath = new Microsoft.AspNetCore.Http.PathString("/Account/Logout"); options.Events.OnValidatePrincipal = PrincipalValidator.ValidateAsync; }); services.AddMvc(); }