Пример #1
0
        public ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                db.userprofiles.Add(userprofile);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(userprofile);
        }
Пример #2
0
 public ActionResult Edit(UserProfile userprofile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userprofile).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(userprofile);
 }
Пример #3
0
 public ActionResult Edit_profile(UserProfile up)
 {
     db.Entry(up).State = EntityState.Modified;
     db.SaveChanges();
     return RedirectToAction("AllProfiles", "Home");
 }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }