protected void ButtonClose_Click(object sender, EventArgs e)
    {
        string    volunteerIdString = Request.QueryString["VolunteerId"];
        int       volunteerId       = Int32.Parse(volunteerIdString);
        Volunteer volunteer         = Volunteer.FromIdentity(volunteerId);

        int    currentUserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
        Person currentUser   = Person.FromIdentity(currentUserId);

        int organizationId = 0;

        Memberships memberships = volunteer.Person.GetMemberships();

        foreach (Membership membership in memberships)
        {
            if (volunteer.Roles.Count > 0 && membership.OrganizationId == volunteer.Roles[0].OrganizationId)
            {
                organizationId = volunteer.Roles[0].OrganizationId; // Assume same org across all roles
            }
        }

        foreach (VolunteerRole role in volunteer.Roles)
        {
            bool assigned = this.ChecksVolunteerRoles.Items.FindByValue(role.Identity.ToString()).Selected;

            role.Close(assigned);

            if (organizationId == role.OrganizationId && assigned)
            {
                // If identified as member, autoassign & log

                volunteer.Person.AddRole(role.RoleType, role.OrganizationId, role.GeographyId);
                PWLog.Write(currentUser, PWLogItem.Person, volunteer.PersonId, PWLogAction.RoleAssigned,
                            "Assigned Role [" + role.RoleType.ToString() + "] for organization [" +
                            Organization.FromIdentity(role.OrganizationId).Name + "] and geography [" +
                            role.Geography.Name + "]", string.Empty);
                Activizr.Logic.Support.PWEvents.CreateEvent(EventSource.PirateWeb, EventType.AddedRole, currentUserId, Organization.PPSEid,
                                                            role.GeographyId, volunteer.PersonId, 0, string.Empty);
            }
        }

        volunteer.Close(this.TextAssessment.Text);

        // Close window and force refresh

        ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
    }
Esempio n. 2
0
    protected void ButtonMarkAsDone_Click(object sender, EventArgs e)
    {
        //Validate that this user is allowed to remove.

        People leads = this.GetDirectReports();

        if (leads.Count > 0)
        {
            bool checkedTooNew = false;
            foreach (string indexString in this.GridOwner.SelectedIndexes)
            {
                int       index       = Int32.Parse(indexString);
                int       volunteerId = (int)this.GridOwner.MasterTableView.DataKeyValues[index]["Identity"];
                Volunteer volunteer   = Volunteer.FromIdentity(volunteerId);
                if (volunteer.OpenedDateTime.AddDays(7) < DateTime.Now)
                {
                    volunteer.Close("Bulk-removed by " + _currentUser.Name);
                }
                else
                {
                    checkedTooNew = true;
                }
            }

            if (checkedTooNew)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "BulkMsg",
                                                    "alert('Note! Some of the volounteers were to new to remove in bulk.\r\n(Needs to be at least a week.)');", true);
            }

            PopulateGrids(false);
            this.GridOwner.Rebind();
            this.GridOther.Rebind();
            this.GridLeadGeography.Rebind();
            this.GridReports.Rebind();
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "BulkMsg",
                                                "alert('Not allowed!');", true);
        }
    }