Пример #1
0
    public static MembershipCreateStatus Register(string Username, string Password, string Email, bool IsApproved, string FirstName, string LastName)
    {
        MembershipCreateStatus CreateStatus;
            Membership.CreateUser(Username, Password, Email, null, null, IsApproved, Guid.NewGuid(), out CreateStatus);

            if (CreateStatus == MembershipCreateStatus.Success)
            {
                using (HomeTaskContext Context = new HomeTaskContext())
                {
                    User User = Context.Users.FirstOrDefault(Usr => Usr.Username == Username);
                    User.FirstName = FirstName;
                    User.LastName = LastName;
                    Context.SaveChanges();
                }

                if (IsApproved)
                {
                    FormsAuthentication.SetAuthCookie(Username, false);
                }
            }

            return CreateStatus;
    }
Пример #2
0
 public CodeFirstRoleProvider()
     : base()
 {
     this.Context = new HomeTaskContext();
 }
Пример #3
0
 public CodeFirstMembershipProvider()
     : base()
 {
     this.Context = new HomeTaskContext();
 }