public ActionResult Create(User user) { //if (ModelState.IsValid) //{ // User usr = new Models.User(); // usr.email = email; // usr.password = model.Password; // usr.firstName = model.firstName; // var email = model.Email; // var password = model.Password; // User newUser = new Models.User(); // newUser.email = email; // //newUser.email = email; // newUser.password = password; // DB_46167_lifetubeEntities register = new DB_46167_lifetubeEntities(); // register.Users.Add(newUser); // register.SaveChanges(); // } //ViewBag.profileid = new SelectList(db.Profiles, "profileid", "firstName", user.profileid); //MailMessage message = new MailMessage(); //message.From = new MailAddress("*****@*****.**"); //message.To.Add(new MailAddress(user.email)); //message.Subject = " Welcome to LifeTube"; //message.Body = " Dear " + user.firstName + " " + user.lastName + "," + Environment.NewLine + "Thank you for joining the Matrix family." + Environment.NewLine + "We encourage you to collaborate with your GM and DGM for continuous success." + Environment.NewLine + "Username:"******" " + user.lastName + " " + Environment.NewLine + "Regards," + Environment.NewLine + "Matrix Admin"; //SmtpClient client = new SmtpClient(); //client.Send(message); return View(); }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userid">Initial value of the userid property.</param> public static User CreateUser(global::System.Int32 userid) { User user = new User(); user.userid = userid; return user; }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
public ActionResult ResetPassword(ResetPasswordModel model) { User usr = new User(); int uId = (from u in db.Users where u.email.Equals(model.Email) select u.userid).Single(); var pin=(from u in db.Users where u.userid==uId select u.resetPin).Single(); if (model.resetPin.Equals(pin.ToString())) { usr = db.Users.Single(u => u.userid == uId); usr.resetPin = ""; usr.password = model.NewPassword; usr.lastModifiedBy = uId; usr.lastModifiedDate = DateTime.Now; db.SaveChanges(); TempData["message"] = "Password updated"; } else { TempData["message"] = "You entered incorrect PIN. Please check your e-mail"; } //return RedirectToAction("LogOn","Account"); return View(); }
public ActionResult SentForgotPassworLink(SentForgotPasswordLinkModel model) { User usr = new User(); var allEmail=(from u in db.Users select u.email).ToArray(); for (int i = 0; i < allEmail.Length; i++) { if (allEmail[i].Equals(model.Email)) { int uId = (from u in db.Users where u.email.Equals(model.Email) select u.userid).Single(); usr = db.Users.Single(u => u.userid == uId); usr.resetPin = GenerateResetPin().ToString(); db.SaveChanges(); var resetPinToSendMail = (from u in db.Users where u.userid == uId select u.resetPin).Single(); MailMessage message = new MailMessage(); message.From = new MailAddress("*****@*****.**"); message.To.Add(new MailAddress(model.Email)); message.Subject = " Set up a new password"; message.Body = "Please click the following link to reset your password." + Environment.NewLine + "Your reset PIN is: " + resetPinToSendMail.ToString() + Environment.NewLine + "http://lifetube.youpixel.com/Account/ResetPassword"; SmtpClient client = new SmtpClient(); client.Send(message); TempData["message"] = "A link has been sent to your e-mail. Please check your mail"; break; } else { TempData["message"] = "This e-mail doesn't exist in LifeTube database. Please try again"; } } return View(); }
public ActionResult Register(RegisterModel model) { User usr = new User(); var uNameValidity = (from u in db.Users select u.email).ToArray(); for (int i = 0; i < uNameValidity.Length; i++) { if (uNameValidity[i].Equals(model.Email)) { GlobalVariables.isValidUserName = false; TempData["message"] = "An account already exist for this e-mail. please try with another e-mail"; break; } else { GlobalVariables.isValidUserName = true; } } if (GlobalVariables.isValidUserName == true) { if (ModelState.IsValid) { Profile p = new Profile(); p.firstName = model.firstName; p.lastName = model.lastName; p.createdOn = DateTime.Now; p.email = model.Email; db.Profiles.AddObject(p); db.SaveChanges(); int pid=(from pr in db.Profiles where pr.email.Equals(model.Email) select pr.profileId).Single(); usr.email = model.Email; usr.password = model.Password; usr.firstName = model.firstName; usr.lastName = model.lastName; usr.phone = model.phone; usr.rootUser = false; usr.profileId = pid; usr.createdDate = DateTime.Now; usr.lastModifiedDate = DateTime.Now; db.Users.AddObject(usr); db.SaveChanges(); // db.Refresh(); MailMessage message = new MailMessage(); message.From = new MailAddress("*****@*****.**"); message.To.Add(new MailAddress(usr.email)); message.Subject = " Welcome to LifeTube.me"; message.Body = "Dear " + usr.firstName + " " + usr.lastName + "," + Environment.NewLine + "Thank you for registering with LifeTube.me" + Environment.NewLine + "Username: "******"Password: "******"Regards," + Environment.NewLine + "LifeTube Admin"; SmtpClient client = new SmtpClient(); client.Send(message); } return RedirectToAction("LogOn", "Account"); } else { return RedirectToAction("Register", "Account"); } }
public ActionResult Edit(User user) { if (ModelState.IsValid) { db.Users.Attach(user); db.ObjectStateManager.ChangeObjectState(user, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.profileid = new SelectList(db.Profiles, "profileid", "firstName", user.profileId); return View(user); }