Ejemplo n.º 1
0
 private void SetAdmin()
 {
     try
     {
         UnitOfWork unitOfWork = new UnitOfWork();
         this._admin = unitOfWork.AdminRepository.Single(u => u.Email.Equals(Ticket.Name), null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public MembershipUser CreateUserBetter(string firstname, string surname, string gender, string email, string password, out MembershipCreateStatus status)
        {
            var args = new ValidatePasswordEventArgs(email, password, true);

            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if (string.IsNullOrEmpty(email))
            {
                status = MembershipCreateStatus.InvalidEmail;
                return null;
            }

            if (string.IsNullOrEmpty(password))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if (RequiresUniqueEmail && EmailExists(email))
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            var u = GetUser(email, false);

            try
            {
                if (u == null)
                {
                    var salt = CreateSalt();

                    //CREATE NEW USER
                    var admin = new Admin
                    {
                        Firstname = firstname,
                        Surname = surname,
                        Gender = gender,
                        Email = email,
                        PasswordSalt = salt,
                        Password = CreatePasswordHash(password, salt),
                        Createddate = DateTime.UtcNow,
                        Lastloggedindate = DateTime.UtcNow
                    };
                    //CREATE USER VIA UNITOFWORK
                    Adapter.AdminRepository.Insert(admin);
                    Adapter.Save();

                    status = MembershipCreateStatus.Success;
                    return GetUser(email, true);
                }
            }
            catch (Exception ex)
            {
                status = MembershipCreateStatus.ProviderError;
                return null;
            }

            status = MembershipCreateStatus.DuplicateUserName;
            return null;
        }
 public AOMembershipUser(string providerName, string name, object providerUserKey, string email, string passwordQuestion, string comment, bool isApproved, bool isLockedOut, DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate, DateTime lastPasswordChangedDate, DateTime lastLockoutDate, Admin admin)
     : base(providerName, name, providerUserKey, email, passwordQuestion, comment, isApproved, isLockedOut, creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate, lastLockoutDate)
 {
     Admin = admin;
 }