private static Charity CreateCharity()
        {
            var charity = new Charity
                              {
                                  Name = TestName,
                              };

            var target = new Charities();

            var actual = target.Insert(charity);
            return actual;
        }
        private static Charity CreateCharity()
        {
            var charity = new Charity
                              {
                                  Name = TestName,
                                  UserId = TestUserId
                              };
            charity.SetPassword(TestPassword);

            var target = new Charities();

            var actual = target.Insert(charity);
            return actual;
        }
        private static Charity CreateCharity()
        {
            var charity = new Charity
                              {
                                  Name = TestName,
                                  UserId = TestUserId,
                                  EncryptedPassword = Encoding.UTF8.GetBytes(TestPassword),
                                  RegisteredCharityNumber = TestRegisteredCharityNumber,
                                  SubDomain = TestSubDomain,
                                  Salt = Encoding.UTF8.GetBytes("passwordSalt")
                              };

            var target = new Charities();

            var actual = target.Insert(charity);
            return actual;
        }
        public bool RegisterUserAndCharity(RegistrationInfo registrationInfo)
        {
            bool result = false;
            var charity = new Charity
            {
                Name = registrationInfo.CharityName,
                RegisteredCharityNumber = registrationInfo.CharityName,
                SubDomain = registrationInfo.SubDomain
            };
            using (var scope = new TransactionScope())
            {
                var newCharity = CharitiesDataAccess.Insert(charity);
                if (newCharity == null) throw new ArgumentNullException("newCharity");


                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(registrationInfo.UserIdentifier, registrationInfo.Password, registrationInfo.UserIdentifier, null, null, true, null, out createStatus);
                var user = Membership.GetUser(registrationInfo.UserIdentifier);
                if (user == null) throw new ArgumentNullException("user");

                var charityMembership = new CharityMembership
                {
                    CharityId = newCharity.Id,
                    UserName = user.UserName
                };
                var newCharityMembership = CharitiesMembershipsDataAccess.Insert(charityMembership);

                if (createStatus == MembershipCreateStatus.Success && newCharityMembership != null)
                {
                    result = true;
                    scope.Complete();
                }
                
            }
            return result;
        }
 public void Delete(Charity charity)
 {
     _db.Charity.DeleteById(charity.Id);
 }
 public void Update(Charity charity)
 {
     _db.Charity.UpdateById(charity);
 }
 public Charity Insert(Charity charity)
 {
     return _db.Charity.Insert(charity);
 }