/// <summary> /// Deprecated Method for adding a new object to the Persons EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPersons(Person person) { base.AddObject("Persons", person); }
public ActionResult Register(RegisterModel model, HttpPostedFileBase fileUpload) { if (User.Identity.IsAuthenticated) return RedirectToAction("Index", "Home"); if (ModelState.IsValid) { MembershipCreateStatus createStatus; //try{ if (Membership.FindUsersByEmail(model.Email).Count != 0) { ModelState.AddModelError(string.Empty, "The email address is in use"); return View(model); } var currentUser = Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); Roles.AddUserToRole(model.UserName,model.Role); if (createStatus == MembershipCreateStatus.Success) { string activationLink = Util.GetAuthKey(Guid.Parse(currentUser.ProviderUserKey.ToString()), model.Email, model.Password); //var emailModel = new //{ // UserName = model.UserName, // Url = string.Format("{0}/Account/Home/?auth={1}", Util.BaseUrl, activationLink) //}; //MailMessage mail = PitchingTubeEntities.Current.GenerateEmail("activation", emailModel); //mail.To.Add(model.Email); //Mailer.SendMail(mail); string avatarPath = ""; if (fileUpload != null) { string path = AppDomain.CurrentDomain.BaseDirectory + "UploadedFiles/"; fileUpload.SaveAs(Path.Combine(path, currentUser.ProviderUserKey.ToString()+".jpg")); avatarPath = "../../UploadedFiles/" + currentUser.ProviderUserKey.ToString()+".jpg"; } else if (!string.IsNullOrWhiteSpace(model.AvatarPath)) { avatarPath = model.AvatarPath; } Person newPerson = new Person { Phone = model.Phone, Skype = model.Skype, UserId = Guid.Parse(currentUser.ProviderUserKey.ToString()), ActivationLink = activationLink.Split('$')[1], AvatarPath = avatarPath, Pay = false, IsPublish = false }; personRepository.Insert(newPerson); FormsAuthentication.SetAuthCookie(model.Email, true); return RedirectToAction("Index","Home"); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } //} //catch(Exception ex) //{ //Membership.DeleteUser(model.UserName); //ModelState.AddModelError("", ex); //} } // If we got this far, something failed, redisplay form return View(model); }
/// <summary> /// Create a new Person object. /// </summary> /// <param name="personId">Initial value of the PersonId property.</param> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="skype">Initial value of the Skype property.</param> /// <param name="phone">Initial value of the Phone property.</param> public static Person CreatePerson(global::System.Int32 personId, global::System.Guid userId, global::System.String skype, global::System.String phone) { Person person = new Person(); person.PersonId = personId; person.UserId = userId; person.Skype = skype; person.Phone = phone; return person; }