public ActionResult EditProfile(Profile profile) { if (ModelState.IsValid) { db.Profiles.Attach(profile); db.ObjectStateManager.ChangeObjectState(profile, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Profile", "Profile"); } return View("profile"); }
/// <summary> /// Create a new Profile object. /// </summary> /// <param name="profileId">Initial value of the profileId property.</param> public static Profile CreateProfile(global::System.Int32 profileId) { Profile profile = new Profile(); profile.profileId = profileId; return profile; }
/// <summary> /// Deprecated Method for adding a new object to the Profiles EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProfiles(Profile profile) { base.AddObject("Profiles", profile); }
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"); } }