public MemberViewModel(Member member, IList<Role> roles) { this._member = member; this._roles = roles; this._profile = new ProfileViewModel(member.Profile); this._id = member.Id; this._password = member.Password; this._username = member.Username; }
/// <summary> /// Creates a new view model to view / edit / create a member /// </summary> /// <param name="website">the website portal we are in</param> /// <param name="member">the member to view / edit or create</param> public MembershipPageViewModel(IWebsite website, Member member, IList<Role> roles) : base(website) { this.Member = new MemberViewModel(member, roles); }
/// <summary> /// Saves the member back to the database /// </summary> /// <param name="member">The member to save</param> /// <param name="transactionManager">a transaction manager to commit the save to the database</param> public void SaveMember(Member member) { try { this._transactionManager.BeginTransaction(); if (!member.Websites.ToList().Exists(o => o.Id == this._website.Id)) { member.Websites.Add(this._website); } this._memberDao.SaveOrUpdate(member); this._transactionManager.CommitTransaction(); } catch (Exception e) { if (this._transactionManager.IsInTransaction()) { this._transactionManager.RollbackTransaction(); } // Add additional data about the member to a new exception ApplicationException exception = new ApplicationException("Probelm saving member", e); exception.Data.Add("Member Id", member.Id); throw exception; } }
/// <summary> /// Changes the members password to the password passed in /// </summary> /// <param name="member">the member to update the password for</param> /// <param name="password">the password</param> public void ChangePassword(Member member, string password) { member.Password = password; this.SaveMember(member); }
public void Delete(Member entity) { throw new NotImplementedException(); }
public Member MapIt(Member member, Profile profile) { member.Profile = profile; return member; }
public Member SaveOrUpdate(Member member) { var db = new PetaPoco.Membership.Database("Portal"); if (member.Id == 0) { this.Save(member); } else { var memberObj = new { MemberId = member.Id, Email = member.Username, Password = member.PasswordHashed }; db.Save("Membership.Members", "MemberId", memberObj); var profile = new { FirstName = member.Profile.FirstName, LastName = member.Profile.LastName, Company = member.Profile.Company, Username = member.Profile.Email, Phone = member.Profile.Phone }; db.Save("Membership.Profiles", "ProfileId", profile); var delete = new { MemberId = member.Id }; db.Delete("Membership.MemberRoles", "MemberRoleId", delete); foreach (var role in member.Roles) { var roleObj = new { RoleId = role.Id, MemberId = member.Id }; db.Save("Membership.MemberRoles", "MemberRoleId", roleObj); } //db.Save("Membership.Members", "Id", member); } return member; }
public Member Save(Member member) { var db = new PetaPoco.Membership.Database("Portal"); db.Insert("Membership.Members", "MemberId", true, member); return member; }