protected UserAccount CreateNewUserAccount(DateTime now) { UserAccount newUserAccount = new UserAccount(); newUserAccount.PartyId = int.Parse(hdnPartyId.Text);//int.Parse(hdnPartyId.Text);//TEMPORARY newUserAccount.UserAccountTypeId = int.Parse(cmbUserAccountType.SelectedItem.Value.ToString()); newUserAccount.Username = txtUsername.Text; newUserAccount.Password = SimplifiedHash.ComputeHash(txtPassword.Text, SimplifiedHash.HashType.sha1); newUserAccount.SecurityQuestion = cmbPasswordQuestion.Text; newUserAccount.SecurityAnswer = txtPasswordAnswer.Text; newUserAccount.DateCreated = now; newUserAccount.EffectiveDate = now; newUserAccount.EndDate = null; ObjectContext.UserAccounts.AddObject(newUserAccount); return newUserAccount; }
public static UserAccountStatu CreateOrUpdateCurrent(UserAccount userAccount, UserAccountStatusType statusType, DateTime today) { UserAccountStatu currentStatus = GetActive(userAccount); if (currentStatus != null && currentStatus.StatusTypeId != statusType.Id) currentStatus.EndDate = today; if (currentStatus == null || currentStatus.StatusTypeId != statusType.Id) { UserAccountStatu newUserAccountStatu = new UserAccountStatu(); newUserAccountStatu.UserAccount = userAccount; newUserAccountStatu.UserAccountStatusType = statusType; newUserAccountStatu.EffectiveDate = today; newUserAccountStatu.EndDate = null; Context.UserAccountStatus.AddObject(newUserAccountStatu); return newUserAccountStatu; } return currentStatus; }
public UserAccountViewModel(UserAccount userAccount) { this.UserAccount = userAccount; this.UserAccountId = userAccount.Id; this.Username = userAccount.Username; this.UserAccountTypeId = userAccount.UserAccountTypeId; this.UserAccountType = userAccount.UserAccountType.Name; this.UserAccountStatus = userAccount.CurrentStatus.UserAccountStatusType.Name; if (userAccount.PartyId.HasValue) { Party party = UserAccount.ObjectContext.Parties.SingleOrDefault(entity => entity.Id == userAccount.PartyId); if (party.PartyTypeId == PartyType.PersonType.Id && party.Person != null) { Person person = party.Person; this.NameOfUser = StringConcatUtility.Build(" ", person.LastNameString + "," , person.FirstNameString, person.MiddleInitialString, person.NameSuffixString); } } }
public static UserAccountStatu GetActive(UserAccount userAccount) { return userAccount.UserAccountStatus.FirstOrDefault(entity => entity.EndDate == null); }