public IActionResult SendMail([FromBody] Models.EmailModel model) { var es = new Services.EmailService(); es.Send(model.To, model.Subject, model.Body); return(Ok()); }
public ActionResult Index() { Stream request = Request.InputStream; request.Seek(0, SeekOrigin.Begin); string json = new StreamReader(request).ReadToEnd(); StripeEvent stripeEvent = null; try { stripeEvent = StripeEventUtility.ParseEvent(json); } catch (Exception e) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, string.Format("Unable to parse incoming event. The following error occured: {0}", e.Message))); } if (stripeEvent == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Incoming event empty")); } var emailService = new Services.EmailService(); switch (stripeEvent.Type) { case StripeEvents.ChargeRefunded: var charge = Mapper <StripeCharge> .MapFromJson(stripeEvent.Data.Object.ToString()); emailService.SendRefundEmail(charge); break; case StripeEvents.CustomerSubscriptionTrialWillEnd: var subscription = Mapper <StripeSubscription> .MapFromJson(stripeEvent.Data.Object.ToString()); emailService.SendTrialEndEmail(subscription); break; case StripeEvents.InvoicePaymentSucceeded: StripeInvoice invoice = Mapper <StripeInvoice> .MapFromJson(stripeEvent.Data.Object.ToString()); var customer = StripeCustomerService.Get(invoice.CustomerId); var user = UserManager.FindByEmail(customer.Email); user.ActiveUntil = user.ActiveUntil.AddMonths(1); UserManager.Update(user); emailService.SendSubscriptionPaymentReceiptEmail(invoice, customer); break; default: break; } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public ActionResult Index() { Stream request = Request.InputStream; request.Seek(0, SeekOrigin.Begin); string json = new StreamReader(request).ReadToEnd(); StripeEvent stripeEvent = null; try { stripeEvent = StripeEventUtility.ParseEvent(json); ///// FOR PRODUCTION TO Confirm that strip send the Events///// FOR PRODUCTION //stripeEvent = VerifyEventSentFromStripe(stripeEvent); // if (HasEventBeenProcessedPreviously(stripeEvent)) { return new HttpStatusCodeResult(HttpStatusCode.OK); }; ///// FOR PRODUCTION TO Confirm that strip send the Events///// FOR PRODUCTION } catch (Exception ex) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest, string.Format("Unable to parse incoming event. The following error occurred: {0}", ex.Message)); } if (stripeEvent == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Incoming event empty"); var emailService = new Services.EmailService(); switch (stripeEvent.Type) { case StripeEvents.ChargeRefunded: var charge = Mapper<StripeCharge>.MapFromJson(stripeEvent.Data.Object.ToString()); emailService.SendRefundEmail(charge); break; case StripeEvents.InvoicePaymentSucceeded : // To generate email to send for confimration var charge2 = Mapper<StripeCharge>.MapFromJson(stripeEvent.Data.Object.ToString()); emailService.SendPaymentReceivedFromInvoicePaymentSucceed(charge2); break; //case StripeEvents.CustomerSubscriptionUpdated: // break; // case StripeEvents.CustomerSubscriptionDeleted: // break; // case StripeEvents.CustomerSubscriptionCreated: // break; //default: // break; } //TODO: log Stripe eventid to StripeEvent table in application database return new HttpStatusCodeResult(HttpStatusCode.OK); }
public ApplicationUserRepository( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IHttpContextAccessor httpContext, IOptions <EmailSettings> emailSettings, PaymentDetailContext db ) : base(db) { _userManager = userManager; _signInManager = signInManager; _httpContext = httpContext; _emailService = new Services.EmailService(emailSettings); _db = db; }
public async Task <ActionResult> Create([Bind(Include = "ID,To,Subject,Message")] Email email) { if (ModelState.IsValid) { db.Emails.Add(email); await db.SaveChangesAsync(); Services.EmailService emailService = new Services.EmailService(); await emailService.SendEmailAsync(email.To, email.Message, email.Subject); return(RedirectToAction("Index")); } return(View(email)); }
public AccountController() { db = new ApplicationDbContext(); emailService = new Services.EmailService(); }
public ActionResult HandleSubmit(RegisterModel model) { var recaptcha = ModelState["ReCaptcha"]; if (recaptcha != null && HttpContext.Request.IsLocal) { recaptcha.Errors.Clear(); } if (!ModelState.IsValid || model.AgreeTerms == false) { if (model.AgreeTerms == false) { ModelState.AddModelError("AgreeTerms", "You can only continue if you agree to our terms and conditions."); } return(CurrentUmbracoPage()); } var memberService = Services.MemberService; if (memberService.GetByEmail(model.Email) != null) { ModelState.AddModelError("Email", "A member with that email address already exists"); return(CurrentUmbracoPage()); } if (string.IsNullOrWhiteSpace(model.Flickr) == false || string.IsNullOrWhiteSpace(model.Bio) == false) { //These fields are hidden, only a bot will know to fill them in //This honeypot catches them return(Redirect("/")); } // these values are enforced in MemberDto which is internal ;-( // we should really have ways to query for Core meta-data! const int maxEmailLength = 400; const int maxLoginNameLength = 200; const int maxPasswordLength = 400; const int maxPropertyLength = 400; if (model.Email != null && model.Email.Length > maxEmailLength || model.Name != null && model.Name.Length > maxLoginNameLength || model.Password != null && model.Password.Length > maxPasswordLength || model.Location != null && model.Location.Length > maxPropertyLength || model.Longitude != null && model.Longitude.Length > maxPropertyLength || model.Latitude != null && model.Latitude.Length > maxPropertyLength || model.TwitterAlias != null && model.TwitterAlias.Length > maxPropertyLength || model.GitHubUsername != null && model.GitHubUsername.Length > maxPropertyLength ) { // has to be a rogue registration // go away! return(Redirect("/")); } var member = memberService.CreateMember(model.Email, model.Email, model.Name, "member"); member.SetValue("location", model.Location); member.SetValue("longitude", model.Longitude); member.SetValue("latitude", model.Latitude); member.SetValue("company", model.Company); member.SetValue("twitter", model.TwitterAlias); member.SetValue("github", model.GitHubUsername); member.SetValue("treshold", "-10"); member.SetValue("bugMeNot", false); member.SetValue("reputationTotal", 20); member.SetValue("reputationCurrent", 20); member.SetValue("forumPosts", 0); member.SetValue("tos", DateTime.Now); member.IsApproved = false; memberService.Save(member); // Now that we have a memberId we can use it var avatarPath = GetAvatarPath(member); member.SetValue("avatar", avatarPath); memberService.Save(member); memberService.AssignRole(member.Username, "standard"); memberService.SavePassword(member, model.Password); Members.Login(model.Email, model.Password); var emailService = new Services.EmailService(); emailService.SendActivationMail(member); memberService.AssignRole(member.Id, "notactivated"); memberService.AssignRole(member.Id, "newaccount"); var redirectPage = "/"; var contentService = ApplicationContext.Current.Services.ContentService; var rootNode = contentService.GetRootContent().OrderBy(x => x.SortOrder).First(x => x.ContentType.Alias == "Community"); var memberNode = rootNode.Children().FirstOrDefault(x => x.Name == "Member"); if (memberNode != null) { var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); var pendingActivationPage = memberNode.Children().FirstOrDefault(x => x.Name == "Pending activation"); if (pendingActivationPage != null) { var pendingActivationContentItem = umbracoHelper.TypedContent(pendingActivationPage.Id); if (pendingActivationContentItem != null) { redirectPage = pendingActivationContentItem.Url; } } } return(Redirect(redirectPage)); }