Ejemplo n.º 1
0
        public void FindByIDFact()
        {
            var membership = default(Membership);

            try
            {
                membership = new Membership(new MembershipEntity());

                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = @"",
                });
                membership.Found += (sender, e) => Assert.NotEqual(MembershipEntity.Empty, e);
                membership.Create();
                Assert.True(0 < membership.ID);

                membership.Find();
                Assert.True(membership.Exists());
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
Ejemplo n.º 2
0
        public void FindByNameFact()
        {
            var membership = default(Membership);

            try
            {
                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = @"",
                });
                membership.Found += (sender, e) =>
                {
                    var actual = new Membership(new MembershipEntity()
                    {
                        Name = e.Name, Password = null,
                    })
                                 .Find();
                    Assert.True(0 < actual.ID);
                };
                membership.Create();
                membership.Find();
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
Ejemplo n.º 3
0
        public void CreateFact()
        {
            var membership = default(Membership);

            try
            {
                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = @"",
                });
                membership.Found += (_, __) =>
                {
                    Assert.Equal(membership.ID, __.ID);
                };
                membership.Create();
                Assert.True(0 < membership.ID);

                Assert.True(membership.Exists());
                membership.Find();
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
Ejemplo n.º 4
0
        protected void ButtonCreate_Click(object sender, EventArgs e)
        {
            string           activistLabel = this.DropActivistLabel.SelectedValue;
            ParticipantTitle peopleLabel   =
                (ParticipantTitle)(Enum.Parse(typeof(ParticipantTitle), this.DropPersonLabel.SelectedValue));
            string asRoot       = this.DropCreateChild.SelectedValue;
            string currencyCode = this.DropCurrencies.SelectedValue;
            string newOrgName   = this.TextOrganizationName.Text;

            if (string.IsNullOrEmpty(newOrgName))
            {
                throw new ArgumentException("Organization name can't be empty");
            }

            if (activistLabel == "0" || peopleLabel == ParticipantTitle.Unknown || asRoot == "0" || currencyCode == "0")
            {
                throw new ArgumentException("Necessary argument was not supplied (did client-side validation run?)");
            }

            Currency     newOrgCurrency = Currency.FromCode(currencyCode);
            Organization parent         = CurrentOrganization;

            if (asRoot == "Root")
            {
                parent = null;
            }

            Organization newOrganization = Organization.Create(parent == null ? 0 : parent.Identity, newOrgName,
                                                               newOrgName, newOrgName, string.Empty, newOrgName, Geography.RootIdentity, true, true, 0);

            newOrganization.EnableEconomy(newOrgCurrency);

            newOrganization.RegularLabel  = peopleLabel;
            newOrganization.ActivistLabel = activistLabel;

            Membership.Create(CurrentUser, newOrganization, DateTime.UtcNow.AddYears(2));

            string successMessage = String.Format(Resources.Pages.Admin.CreateOrganization_Success,
                                                  Participant.Localized(peopleLabel, TitleVariant.Ship));

            Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode(successMessage)));

            // Log in to new organization, then redirect to Edit

            Response.Redirect(
                "/Pages/v5/Security/SetCurrentOrganization.aspx?OrganizationId=" +
                newOrganization.Identity.ToString(CultureInfo.InvariantCulture) +
                "&ReturnUrl=/Pages/v5/Admin/EditOrganization.aspx", true);
        }
Ejemplo n.º 5
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            DateTime dateOfBirth = new DateTime(1800, 1, 1);  // null equivalent

            if (this.TextDateOfBirth.Text.Length > 0)
            {
                dateOfBirth = DateTime.Parse(this.TextDateOfBirth.Text);
            }

            string street = this.TextStreet1.Text;

            if (!string.IsNullOrEmpty(this.TextStreet2.Text))
            {
                street += "|" + this.TextStreet2.Text;
            }

            Person newPerson = Person.Create(this.TextName.Text, this.TextMail.Text, string.Empty, this.TextPhone.Text,
                                             street, this.TextPostal.Text, this.TextCity.Text, this.DropCountries.SelectedValue, dateOfBirth,
                                             (PersonGender)Enum.Parse(typeof(PersonGender), this.DropGenders.SelectedValue));

            Membership newMembership = Membership.Create(newPerson, CurrentOrganization, DateTime.Today.AddYears(1));

            OutboundComm.CreateMembershipLetter(ParticipantMailType.MemberAddedWelcome, newMembership, CurrentUser);

            SwarmopsLogEntry logEntry = SwarmopsLog.CreateEntry(newPerson,
                                                                new Swarmops.Logic.Support.LogEntries.PersonAddedLogEntry(newMembership, CurrentUser));

            logEntry.CreateAffectedObject(newMembership);
            logEntry.CreateAffectedObject(CurrentUser);

            // Clear form and make way for next person

            this.TextName.Text             = string.Empty;
            this.TextStreet1.Text          = string.Empty;
            this.TextStreet2.Text          = string.Empty;
            this.TextMail.Text             = string.Empty;
            this.TextPhone.Text            = string.Empty;
            this.TextPostal.Text           = string.Empty;
            this.TextCity.Text             = string.Empty;
            this.TextDateOfBirth.Text      = string.Empty;
            this.DropGenders.SelectedValue = "Unknown";

            this.TextName.Focus();
            this.LiteralLoadAlert.Text = Resources.Pages.Swarm.AddPerson_PersonSuccessfullyRegistered;
        }
        public void CreateFact()
        {
            var membership = default(Membership);
            var user       = default(User);

            try
            {
                user = new User(new UserEntity());
                user.Create();

                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name,
                });
                membership.Users.Add(user.ID);
                membership.Create();
                membership.Find();

                user.Find();

                Assert.Equal(membership.ID, user.MembershipID);
                Assert.Contains(user.ID, membership.Users);
            }
            finally
            {
                if (user != null)
                {
                    user.Delete();
                }
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
Ejemplo n.º 7
0
        public void ExistsFact()
        {
            var membership = default(Membership);

            try
            {
                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = null,
                });
                membership.Create();

                Assert.True(Membership.Exists(name));
                Assert.True(membership.Exists());
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }