Ejemplo n.º 1
0
        private static Charity CreateCharity()
        {
            var charity = new Charity
                              {
                                  Name = TestName,
                              };

            var target = new Charities();

            var actual = target.Insert(charity);
            return actual;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 5
0
 public void Delete(Charity charity)
 {
     _db.Charity.DeleteById(charity.Id);
 }
Ejemplo n.º 6
0
 public void Update(Charity charity)
 {
     _db.Charity.UpdateById(charity);
 }
Ejemplo n.º 7
0
 public Charity Insert(Charity charity)
 {
     return _db.Charity.Insert(charity);
 }