public void CanUpdateMember()
        {
            //first create one
            var m = new Member();
            m.Email = "*****@*****.**";
            m.FirstName = "Emmitt";
            m.LastName = "Carter";
            m.HashedPassword = "******";
            m.PasswordSalt = "blee";

            //remove previous ones
            DeleteMember(m.Email);

            //persist
            var repo = CreateRepository();
            Assert.IsTrue(m.MemberID == 0);
            repo.Save(m);

            //update
            Assert.AreEqual("Emmitt", m.FirstName);
            m.FirstName = "Riley";
            repo.Save(m);

            //re-get
            var m2 = repo.Find(m.MemberID);
            Assert.AreEqual("Riley", m.FirstName);
        }
 public ServiceResponse CreateMember(Member member, string originalPassword)
 {
     var result = new ServiceResponse();
     member.PasswordSalt = CreateSalt();
     member.HashedPassword = _formsAuth.HashPasswordForStoringInConfigFile(originalPassword + member.PasswordSalt, "sha1");
     _memberRepo.Save(member);
     return result;
 }
Beispiel #3
0
 public void CanCreateMember()
 {
     var chris = new Member();
     chris.Email = "*****@*****.**";
     chris.FirstName = "Chris";
     chris.LastName = "Carter";
     chris.CreateDate = DateTime.Now;
     var service = CreateSecurityService();
     service.CreateMember(chris, "quickbrownfox");
 }
 public void CanCreateNewMember()
 {
     var m = new Member();
     m.Email = "*****@*****.**";
     m.FirstName = "Emmitt";
     m.LastName = "Carter";
     m.HashedPassword = "******";
     m.PasswordSalt = "blee";
     DeleteMember(m.Email);
     var repo = CreateRepository();
     repo.Save(m);
     Assert.IsTrue(m.MemberID > 0);
     Console.WriteLine(m.MemberID);
 }
 public void Save(Member member)
 {
     var sql = @"
     if exists(select * from member where memberid=@memberid)
     begin
     update member set
     Email=@Email,
     PasswordSalt=@PasswordSalt,
     HashedPassword=@HashedPassword,
     FirstName=@FirstName,
     LastName=@LastName
     where memberid = @memberid
     select @memberid as 'memberid'
     end
     else
     begin
     insert into member(
     Email,
     PasswordSalt,
     HashedPassword,
     FirstName,
     LastName,
     CreateDate
     )values(
     @Email,
     @PasswordSalt,
     @HashedPassword,
     @FirstName,
     @LastName,
     getdate()
     )
     select scope_identity() as 'memberid'
     end
     ";
     using (var cmd = new SqlCommand(sql))
     {
         cmd.Parameters.Add("@MemberID", SqlDbType.Int).Value = member.MemberID;
         cmd.Parameters.Add("@Email", SqlDbType.VarChar, 100).Value = member.Email;
         cmd.Parameters.Add("@PasswordSalt", SqlDbType.VarChar, 1000).Value = member.PasswordSalt;
         cmd.Parameters.Add("@HashedPassword", SqlDbType.VarChar, 500).Value = member.HashedPassword;
         cmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value = member.FirstName;
         cmd.Parameters.Add("@LastName", SqlDbType.VarChar, 50).Value = member.LastName;
         member.MemberID = _helper.ExecuteScalar<int>(cmd);
     }
 }
 public void Save(Project project, Member member)
 {
     Save(project, member.MemberID);
 }