コード例 #1
0
ファイル: AccountController.cs プロジェクト: tinavas/paymobd
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, passwordQuestion: null, passwordAnswer: null, isApproved: true, providerUserKey: null, status: out createStatus);

                UserProfile up = new UserProfile();
                up.username = model.UserName;
                up.password = model.Password;
                up.e_mail = model.Email;
                up.join_date = DateTime.Now;
                up.wallet_money = 0;
                db.userprofiles.Add(up);
                db.SaveChanges();
                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, createPersistentCookie: true);
                    return RedirectToAction("myprofile", "Home");
                }
                else
                {
                    ModelState.AddModelError(" ", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: tinavas/paymobd
        public ActionResult Register_bangla(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, passwordQuestion: null, passwordAnswer: null, isApproved: true, providerUserKey: null, status: out createStatus);

                UserProfile up = new UserProfile();
                up.username = model.UserName;
                up.password = model.Password;
                up.e_mail = model.Email;
                up.join_date = DateTime.Now;
                up.wallet_money = 0;
                db.userprofiles.Add(up);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    db.SaveChanges();
                    FormsAuthentication.SetAuthCookie(model.UserName, createPersistentCookie: true);

                    //send mail
                    MailMessage message = new MailMessage();
                    var fromAddress = "*****@*****.**";
                    // any address where the email will be sending
                    var toAddress = model.Email;
                    //Password of your gmail address
                    const string fromPassword = "******";
                    // Passing the values and make a email formate to display
                    string subject = "Welcome to PayMoBD";
                    string body = string.Format("Hello {0}. Welcome to PayMoBD.com. Your PayMoBD.com login informations are Username:{1} and Password:{2}. PLease contatct [email protected] if you forget your password.",
                        model.UserName, model.UserName, model.Password);

                    // smtp settings
                    SmtpClient smtp = new SmtpClient
                    {
                        Host = "mail.paymobd.com",
                        Port = 587,
                        EnableSsl = false,
                        //DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                        Credentials = new NetworkCredential(fromAddress, fromPassword)
                        //  smtp.Timeout = 20000;

                    };
                    try
                    {
                        smtp.Send(fromAddress, toAddress, subject, body);
                    }
                    catch
                    {
                        return RedirectToAction("Register_error");
                    }
                    return RedirectToAction("myprofile_bangla", "Home");
                }
                else
                {
                    ModelState.AddModelError(" ", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }