public async Task <ActionResult> SendEmailConfirm()
        {
            try
            {
                string code = await UserManager.GenerateEmailConfirmationTokenAsync(User.Identity.GetUserId());

                var    callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = User.Identity.GetUserId(), code = code }, protocol: Request.Url.Scheme);
                string emailBody   = EmailTemplatesService.GetVerifyEmailHTML(callbackUrl);
                await UserManager.SendEmailAsync(User.Identity.GetUserId(), "熊i猜Email驗證信", emailBody);
            }
            catch (Exception e)
            {
            }
            return(RedirectToAction("Index", new { Message = ManageMessageId.SendEmailConfirmSuccess }));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> LiveApply(ApplyLiveViewModel model)
        {
            if (ModelState.IsValid && new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"]))
            {
                //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                // 傳送包含此連結的電子郵件
                //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, "熊i猜Email驗證信", "請按此連結確認您的帳戶 <a href=\"" + callbackUrl + "\">驗證</a>");
                var apply = new LiveApply
                {
                    name          = model.Name,
                    Email         = model.Email,
                    livecount     = model.livecount,
                    comment       = model.comment,
                    valid         = 0,
                    lievlink      = model.lievlink,
                    inpdate       = DateTime.Now,
                    createComment = model.createComment
                };

                new UserRepository().applylive(apply);


                var content = "<h2 style='text-align: center;'>申請通知信</h2>" +
                              "<div style='text-align: center;padding:0 14%;'>" +
                              "<h4 style='color:#222'>親愛的直播主您好:<p>" +
                              "我們已經收到您的申請<p>" +
                              "<h3 style='color:#500050'>熊i猜會在5~7個工作日審核您的資格,審核通過將為您寄送相關文件及合約書至您的信箱,還請您耐心等候,如有任何問題,可至<a href='https://www.facebook.com/funbet.esport/'>熊i猜粉絲團</a>發訊詢問喔!<br>" +
                              "(本通知為自動發送,請勿直接回信詢問,以避免延誤問題解決時間。)</h3><br>";
                var EmailContent = EmailTemplatesService.GetLiveEmailHTML(content);
                //寄送通知信
                new MailServiceMailgun().ChangeSend("競猜直播主申請通知信", EmailContent, model.Email, "");



                return(RedirectToAction("Index", "Home", new { message = "申請成功,已寄送通知信至你的信箱" }));
            }

            // 如果執行到這裡,發生某項失敗,則重新顯示表單
            return(View(model));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid && new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"]))
            {
                var user = new ApplicationUser {
                    UserName = model.Name, Email = model.Email, Name = model.Name, RegistrationDate = DateTime.Now
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // 傳送包含此連結的電子郵件
                    //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, "熊i猜Email驗證信", "請按此連結確認您的帳戶 <a href=\"" + callbackUrl + "\">驗證</a>");
                    await new AccountModel().RegisterFinsh(user);

                    //寄送驗證信件
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var    callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    string emailBody   = EmailTemplatesService.GetVerifyEmailHTML(callbackUrl);
                    await UserManager.SendEmailAsync(user.Id, "熊i猜Email驗證信", emailBody);



                    return(RedirectToAction("RegisterFinish", "Account"));
                }
                AddErrors(result);
            }

            // 如果執行到這裡,發生某項失敗,則重新顯示表單
            return(View(model));
        }
Ejemplo n.º 4
0
 public EmailTemplatesController(EmailTemplatesService service)
 {
     _service = service;
 }
        public int MallChange(int id, float?money, string name, string phone, string address)
        {
            var userId = User.Identity.GetUserId();
            // var malldata = new MangerRepository().GetTransferRecords(userId);
            Product product = new MallRepository().Get(id);
            // 1 現金換魚骨 -2 兌獎 -3 鮭魚換魚骨

            int offer = 100;

            List <Preferential> pft = new PreferentialRepository().getAllvaild();

            if (pft != null)
            {
                if (pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault() != null)
                {
                    offer = (int)pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                }

                foreach (var pt in pft.Where(x => x.offerModel == 3))
                {
                    if (pt.productId == id)
                    {
                        offer = (int)pft.Where(x => x.offerModel == 3 && x.productId == id).FirstOrDefault().offer;
                    }
                }
            }

            ProductRecord assr = new ProductRecord
            {
                UserID    = User.Identity.GetUserId(),
                unitSn    = product.unitSn,
                assets    = (money != null) ? -money : -product.Price * offer / 100,
                inpdate   = DateTime.Now,
                type      = (money != null)?-3:-2,
                ProductId = product.id,
                recipient = name,
                phone     = phone,
                address   = address
            };
            bool aset = new AssetsRepository().AddBearByAssets(assr);

            if (product.unitSn == 2 && product.type == 3)
            {
                assr = new ProductRecord
                {
                    UserID    = User.Identity.GetUserId(),
                    unitSn    = 1,
                    assets    = money * product.Price,
                    inpdate   = DateTime.Now,
                    type      = 3,
                    ProductId = product.id,
                    recipient = name,
                    phone     = phone,
                    address   = address
                };
                aset = new AssetsRepository().AddBearByAssets(assr);
            }
            if (money == null)
            {
                var m = Math.Ceiling((double)product.Price / 1.2 / 30000 * 30);
                var d = 0;
                if (m < 1000)
                {
                    d = 1;
                }
                else if (999 < m && m < 20000)
                {
                    d = 2;
                }
                else if (m > 19999)
                {
                    d = 3;
                }
                var    user         = UserManager.FindById(User.Identity.GetUserId());
                var    content      = ConfirmChange(d, assr, product);
                var    EmailContent = EmailTemplatesService.GetChangeEmailHTML(content);
                var    h            = Server.MapPath("\\Content\\Pdf\\Change\\");
                string url          = (product.pdf_file != null) ?  product.pdf_file : "";
                new MailServiceMailgun().ChangeSend("熊i猜兌獎通知信", EmailContent, user.Email, url);
            }



            return(aset?1:0);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid && new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"]))
            {
                var user = new ApplicationUser {
                    UserName = model.Name, Email = model.Email, Name = model.Name, RegistrationDate = DateTime.Now
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // 傳送包含此連結的電子郵件
                    //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, "熊i猜Email驗證信", "請按此連結確認您的帳戶 <a href=\"" + callbackUrl + "\">驗證</a>");
                    await new AccountModel().RegisterFinsh(user);

                    //寄送驗證信件
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var    callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    string emailBody   = EmailTemplatesService.GetVerifyEmailHTML(callbackUrl);
                    await UserManager.SendEmailAsync(user.Id, "熊i猜Email驗證信", emailBody);

                    if (model.Code != "")
                    {
                        var r = new UserRepository().getRecommend();
                        foreach (var re in r)
                        {
                            var v = new UserRepository().getRecommendStart((int)re.ReId);
                            if (v.edate > DateTime.Now)
                            {
                                if (model.Code == re.code)
                                {
                                    AssetsRecord ar = new AssetsRecord();
                                    ar.assets = (double)v.money;
                                    ar.unitSn = 1;
                                    ar.UserId = user.Id;
                                    new AssetsRepository().AddAssetsByAssets(ar);
                                }
                            }
                        }
                    }
                    if (model.Assets > 5000)
                    {
                        model.Assets = 5000;
                    }

                    if (model.Assets != 0)
                    {
                        AssetsRecord ar2 = new AssetsRecord();
                        ar2.assets = (double)model.Assets;
                        ar2.unitSn = 1;
                        ar2.UserId = user.Id;

                        new AssetsRepository().AddAssetsByAssets(ar2);
                    }
                    var prm = new PreferentialRecords
                    {
                        UserId         = user.Id,
                        Count          = 0,
                        inpdate        = DateTime.Now,
                        PreferentialID = 100
                    };

                    new PreferentialRepository().PRecordsCreate(prm);



                    return(RedirectToAction("Index", "Manage", new { RM = "溫馨提醒:Email以及手機驗證,才可以參與所有競猜活動!!" }));
                }

                AddErrors(result);
            }

            // 如果執行到這裡,發生某項失敗,則重新顯示表單
            return(View(model));
        }